Esempio n. 1
0
        public static byte[] CompileConsoleApp(string sourceCode)
        {
            // create the Roslyn compilation for the main program with
            // ConsoleApplication compilation options
            // adding references to A.netmodule and B.netmodule
            var mainCompilation =
                DotNetCompiler.CreateCompilationWithMscorlib
                (
                    "program",
                    sourceCode,
                    compilerOptions: new CSharpCompilationOptions(OutputKind.ConsoleApplication)
                );

            // emit the compilation result to a byte array
            // corresponding to A.netmodule byte code
            byte[] result = DotNetCompiler.EmitToArray(mainCompilation);

            return(result);
        }