SHOW:
|
|
- or go back to the newest paste.
1 | using System; | |
2 | using System.IO; | |
3 | using System.Reflection; | |
4 | using Roslyn.Compilers; | |
5 | using Roslyn.Compilers.CSharp; | |
6 | ||
7 | internal static class Program | |
8 | { | |
9 | private static void Main() { | |
10 | var text = @"enum E { A } class P { const E E = E.A; static void Main() { } }"; | |
11 | var tree = SyntaxTree.ParseText(text); | |
12 | var mscorlib = MetadataReference.CreateAssemblyReference("mscorlib"); | |
13 | var options = new CompilationOptions(OutputKind.ConsoleApplication); | |
14 | var compilation = Compilation.Create("X", options, new[] { tree, }, new[] { mscorlib, }); | |
15 | - | EmitResult result; |
15 | + | var result = compilation.Emit(Stream.Null); |
16 | - | using(var stream = new MemoryStream()) { |
16 | + | |
17 | - | result = compilation.Emit(stream); |
17 | + | |
18 | - | }//using |
18 | + | |
19 | Console.WriteLine(output); | |
20 | } | |
21 | } |