public static T WithReferenceAssemblies <T>(this T compilation, ReferenceAssemblyKind kind) where T : Compilation { var references = ReferenceAssemblies.Get(kind); return((T)(compilation.WithReferences(references))); }
public void AllCanCompile() { var source = @" using System; public class C { public Exception Exception; static void Main() { Console.WriteLine(""Hello World""); } }"; foreach (var kind in Enum.GetValues <ReferenceAssemblyKind>()) { var compilation = CSharpCompilation.Create( "Example", new[] { CSharpSyntaxTree.ParseText(source) }, references: ReferenceAssemblies.Get(kind)); Assert.Empty(compilation.GetDiagnostics()); using var stream = new MemoryStream(); var emitResult = compilation.Emit(stream); Assert.True(emitResult.Success); Assert.Empty(emitResult.Diagnostics); } }