private int RunInteractiveCore(ErrorLogger errorLogger) { Debug.Assert(_compiler.Arguments.IsScriptRunner); var sourceFiles = _compiler.Arguments.SourceFiles; if (_compiler.Arguments.DisplayVersion) { _compiler.PrintVersion(_console.Out); return(0); } if (_compiler.Arguments.DisplayLangVersions) { _compiler.PrintLangVersions(_console.Out); return(0); } if (sourceFiles.IsEmpty && _compiler.Arguments.DisplayLogo) { _compiler.PrintLogo(_console.Out); if (!_compiler.Arguments.DisplayHelp) { _console.Out.WriteLine(ScriptingResources.HelpPrompt); } } if (_compiler.Arguments.DisplayHelp) { _compiler.PrintHelp(_console.Out); return(0); } SourceText code = null; var diagnosticsInfos = new List <DiagnosticInfo>(); if (!sourceFiles.IsEmpty) { if (sourceFiles.Length > 1 || !sourceFiles[0].IsScript) { diagnosticsInfos.Add( new DiagnosticInfo( _compiler.MessageProvider, _compiler.MessageProvider.ERR_ExpectedSingleScript ) ); } else { code = _compiler.TryReadFileContent(sourceFiles[0], diagnosticsInfos); } } // only emit symbols for non-interactive mode, var emitDebugInformation = !_compiler.Arguments.InteractiveMode; var scriptPathOpt = sourceFiles.IsEmpty ? null : sourceFiles[0].Path; var scriptOptions = GetScriptOptions( _compiler.Arguments, scriptPathOpt, _compiler.MessageProvider, diagnosticsInfos, emitDebugInformation ); var errors = _compiler.Arguments.Errors.Concat( diagnosticsInfos.Select(Diagnostic.Create) ); if (_compiler.ReportDiagnostics(errors, _console.Error, errorLogger, compilation: null)) { return(CommonCompiler.Failed); } var cancellationToken = new CancellationToken(); if (_compiler.Arguments.InteractiveMode) { RunInteractiveLoop(scriptOptions, code?.ToString(), cancellationToken); return(CommonCompiler.Succeeded); } else { return(RunScript(scriptOptions, code, errorLogger, cancellationToken)); } }