Esempio n. 1
0
 public IEnumerable <IDiagnostic> GetCompilationErrors(SourceCode post)
 {
     using (var stream = new MemoryStream())
     {
         var result = compiler.Compile(post).Emit(stream);
         return(result.Diagnostics);
     }
 }
Esempio n. 2
0
        public ExecutionResult Execute(SourceCode sourceCode, TimeSpan timeout)
        {
            var compilation = compiler.Compile(sourceCode);

            byte[] compiledAssembly;
            using (var stream = new MemoryStream())
            {
                var emitResult = compilation.Emit(stream);

                if (!emitResult.Success)
                {
                    return(new ExecutionResult {
                        Result = "[Compilation failed]"
                    });
                }

                compiledAssembly = stream.ToArray();
            }

            var sandbox = new Sandbox(compiledAssembly);

            return(sandbox.Run("EntryPoint", "Result", timeout));
        }
Esempio n. 3
0
        public ExecutionResult Execute(Post post)
        {
            var compilation = compiler.Compile(post);

            byte[] compiledAssembly;
            using (var stream = new MemoryStream())
            {
                var emitResult = compilation.Emit(stream);

                if (!emitResult.Success)
                {
                    return(new ExecutionResult {
                        Result = "[Compilation failed]"
                    });
                }

                compiledAssembly = stream.ToArray();
            }

            using (var sandbox = new Sandbox(compiledAssembly))
            {
                return(sandbox.Run("EntryPoint", "Result", TimeSpan.FromSeconds(5)));
            }
        }
Esempio n. 4
0
        public IEnumerable <IDiagnostic> GetCompilationErrors(Post post)
        {
            var result = compiler.Compile(post).Emit();

            return(result.Diagnostics);
        }