public EasyEndpointCodeFixTest() { var refs = new ReferenceAssemblies("net6.0", new PackageIdentity("Microsoft.NETCore.App.Ref", "6.0.0"), Path.Combine("ref", "net6.0")); var package = System.Collections.Immutable.ImmutableArray.Create(new PackageIdentity("Easy.Endpoints.Core", "3.1.0")); refs = refs.AddPackages(package); ReferenceAssemblies = refs; }
private async Task <CSharpCompilation> CreateCompilationAsync(ReferenceAssemblies references) { ImmutableArray <MetadataReference> metadataReferences = await references .AddPackages(ImmutableArray.Create(new PackageIdentity("Microsoft.Windows.SDK.Contracts", "10.0.19041.1"))) .ResolveAsync(LanguageNames.CSharp, default); // Workaround for https://github.com/dotnet/roslyn-sdk/issues/699 metadataReferences = metadataReferences.AddRange( Directory.GetFiles(Path.Combine(Path.GetTempPath(), "test-packages", "Microsoft.Windows.SDK.Contracts.10.0.19041.1", "ref", "netstandard2.0"), "*.winmd").Select(p => MetadataReference.CreateFromFile(p))); // CONSIDER: How can I pass in the source generator itself, with AdditionalFiles, so I'm exercising that code too? var compilation = CSharpCompilation.Create( assemblyName: "test", references: metadataReferences, options: new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary, allowUnsafe: true)); // Add a namespace that WinUI projects define to ensure we prefix types with "global::" everywhere. compilation = compilation.AddSyntaxTrees( CSharpSyntaxTree.ParseText("namespace Microsoft.System { }", this.parseOptions, path: "Microsoft.System.cs")); return(compilation); }