Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Reflection;
- using Roslyn.Compilers;
- using Roslyn.Compilers.CSharp;
- internal static class Program
- {
- private static void Main() {
- var text = @"enum E { A } class P { const E E = E.A; static void Main() { } }";
- var tree = SyntaxTree.ParseText(text);
- var mscorlib = MetadataReference.CreateAssemblyReference("mscorlib");
- var options = new CompilationOptions(OutputKind.ConsoleApplication);
- var compilation = Compilation.Create("X", options, new[] { tree, }, new[] { mscorlib, });
- var result = compilation.Emit(Stream.Null);
- var output = result.GetType()
- .GetProperty("DebuggerDisplay", BindingFlags.Instance | BindingFlags.NonPublic)
- .GetValue(result);
- Console.WriteLine(output);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement