7
7
using Microsoft . CodeAnalysis . CSharp ;
8
8
using Microsoft . CodeAnalysis . Text ;
9
9
10
- using XunitAssert = Xunit . Assert ;
11
10
using System . Net . Http ;
12
11
using System . Collections . Concurrent ;
13
12
using System . Collections . ObjectModel ;
@@ -16,76 +15,13 @@ namespace FluentAssertions.Analyzers.TestUtils
16
15
{
17
16
public class CsProjectGenerator
18
17
{
19
- static CsProjectGenerator ( )
20
- {
21
- References = new [ ]
22
- {
23
- typeof ( object ) , // System.Private.CoreLib
24
- typeof ( Console ) , // System
25
- typeof ( Uri ) , // System.Private.Uri
26
- typeof ( Enumerable ) , // System.Linq
27
- typeof ( CSharpCompilation ) , // Microsoft.CodeAnalysis.CSharp
28
- typeof ( Compilation ) , // Microsoft.CodeAnalysis
29
- typeof ( AssertionScope ) , // FluentAssertions.Core
30
- typeof ( AssertionExtensions ) , // FluentAssertions
31
- typeof ( HttpRequestMessage ) , // System.Net.Http
32
- typeof ( ImmutableArray ) , // System.Collections.Immutable
33
- typeof ( ConcurrentBag < > ) , // System.Collections.Concurrent
34
- typeof ( ReadOnlyDictionary < , > ) , // System.ObjectModel
35
- typeof ( Microsoft . VisualStudio . TestTools . UnitTesting . Assert ) , // MsTest
36
- typeof ( XunitAssert ) , // Xunit
37
- } . Select ( type => type . GetTypeInfo ( ) . Assembly . Location )
38
- . Append ( GetSystemAssemblyPathByName ( "System.Globalization.dll" ) )
39
- . Append ( GetSystemAssemblyPathByName ( "System.Text.RegularExpressions.dll" ) )
40
- . Append ( GetSystemAssemblyPathByName ( "System.Runtime.Extensions.dll" ) )
41
- . Append ( GetSystemAssemblyPathByName ( "System.Data.Common.dll" ) )
42
- . Append ( GetSystemAssemblyPathByName ( "System.Threading.Tasks.dll" ) )
43
- . Append ( GetSystemAssemblyPathByName ( "System.Runtime.dll" ) )
44
- . Append ( GetSystemAssemblyPathByName ( "System.Reflection.dll" ) )
45
- . Append ( GetSystemAssemblyPathByName ( "System.Xml.dll" ) )
46
- . Append ( GetSystemAssemblyPathByName ( "System.Xml.XDocument.dll" ) )
47
- . Append ( GetSystemAssemblyPathByName ( "System.Private.Xml.Linq.dll" ) )
48
- . Append ( GetSystemAssemblyPathByName ( "System.Linq.Expressions.dll" ) )
49
- . Append ( GetSystemAssemblyPathByName ( "System.Collections.dll" ) )
50
- . Append ( GetSystemAssemblyPathByName ( "netstandard.dll" ) )
51
- . Append ( GetSystemAssemblyPathByName ( "System.Xml.ReaderWriter.dll" ) )
52
- . Append ( GetSystemAssemblyPathByName ( "System.Private.Xml.dll" ) )
53
- . Select ( location => ( MetadataReference ) MetadataReference . CreateFromFile ( location ) )
54
- . ToImmutableArray ( ) ;
55
-
56
- string GetSystemAssemblyPathByName ( string assemblyName )
57
- {
58
- var root = System . IO . Path . GetDirectoryName ( typeof ( object ) . Assembly . Location ) ;
59
- return System . IO . Path . Combine ( root , assemblyName ) ;
60
- }
61
- }
62
-
63
- private static readonly ImmutableArray < MetadataReference > References ;
64
-
65
18
private static readonly string DefaultFilePathPrefix = "Test" ;
66
19
private static readonly string CSharpDefaultFileExt = "cs" ;
67
20
private static readonly string VisualBasicDefaultExt = "vb" ;
68
21
private static readonly string TestProjectName = "TestProject" ;
69
22
70
23
public static Document CreateDocument ( CsProjectArguments arguments ) => CreateProject ( arguments ) . Documents . First ( ) ;
71
24
72
- /// <summary>
73
- /// Create a project using the inputted strings as sources.
74
- /// </summary>
75
- /// <param name="sources">Classes in the form of strings</param>
76
- /// <param name="language">The language the source code is in</param>
77
- /// <returns>A Project created out of the Documents created from the source strings</returns>
78
- public static Project CreateProject ( string [ ] sources , string language = LanguageNames . CSharp )
79
- {
80
- var arguments = new CsProjectArguments
81
- {
82
- Language = language ,
83
- Sources = sources ,
84
- TargetFramework = TargetFramework . Net8_0 ,
85
- } ;
86
- return CreateProject ( arguments ) . AddMetadataReferences ( References ) ;
87
- }
88
-
89
25
public static Project CreateProject ( CsProjectArguments arguments )
90
26
{
91
27
string fileNamePrefix = DefaultFilePathPrefix ;
0 commit comments