private int RunScript(ScriptOptions options, SourceText code, ErrorLogger errorLogger, CancellationToken cancellationToken) { var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter); globals.Args.AddRange(_compiler.Arguments.ScriptArguments); var script = Script.CreateInitialScript <int>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null); try { return(script.RunAsync(globals, cancellationToken).GetAwaiter().GetResult().ReturnValue); } catch (CompilationErrorException e) { _compiler.ReportErrors(e.Diagnostics, _console.Error, errorLogger); return(CommonCompiler.Failed); } }
private int RunScript(ScriptOptions options, string code, string scriptPath, ErrorLogger errorLogger, CancellationToken cancellationToken) { var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter); globals.Args.AddRange(_compiler.Arguments.ScriptArguments); options = options.WithPath(scriptPath).WithIsInteractive(false); var script = Script.CreateInitialScript <object>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null); try { script.RunAsync(globals, cancellationToken).Wait(); // TODO: use the return value of the script https://github.com/dotnet/roslyn/issues/5773 return(CommonCompiler.Succeeded); } catch (CompilationErrorException e) { _compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger); return(CommonCompiler.Failed); } }
private int RunScript(ScriptOptions options, string code, ErrorLogger errorLogger, CancellationToken cancellationToken) { var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter); globals.Args.AddRange(_compiler.Arguments.ScriptArguments); var script = Script.CreateInitialScript<object>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null); try { script.RunAsync(globals, cancellationToken).Wait(); // TODO: use the return value of the script https://github.com/dotnet/roslyn/issues/5773 return CommonCompiler.Succeeded; } catch (CompilationErrorException e) { _compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger); return CommonCompiler.Failed; } }
private int RunScript(ScriptOptions options, string code, ErrorLogger errorLogger, CancellationToken cancellationToken) { var globals = new CommandLineScriptGlobals(_console.Out, _objectFormatter); globals.Args.AddRange(_compiler.Arguments.ScriptArguments); var script = Script.CreateInitialScript<int>(_scriptCompiler, code, options, globals.GetType(), assemblyLoaderOpt: null); try { return script.RunAsync(globals, cancellationToken).Result.ReturnValue; } catch (CompilationErrorException e) { _compiler.ReportErrors(e.Diagnostics, _console.Out, errorLogger); return CommonCompiler.Failed; } }