/// <summary> /// csi.exe and vbi.exe entry point. /// </summary> private int RunInteractiveCore(ErrorLogger errorLogger) { Debug.Assert(_compiler.Arguments.IsScriptRunner); var sourceFiles = _compiler.Arguments.SourceFiles; 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); } } var scriptPathOpt = sourceFiles.IsEmpty ? null : sourceFiles[0].Path; var scriptOptions = GetScriptOptions(_compiler.Arguments, scriptPathOpt, _compiler.MessageProvider, diagnosticsInfos); var errors = _compiler.Arguments.Errors.Concat(diagnosticsInfos.Select(Diagnostic.Create)); if (_compiler.ReportErrors(errors, _console.Error, errorLogger)) { return(CommonCompiler.Failed); } var cancellationToken = new CancellationToken(); if (_compiler.Arguments.InteractiveMode) { RunInteractiveLoop(scriptOptions, code?.ToString(), cancellationToken); return(CommonCompiler.Succeeded); } else { return(RunScript(scriptOptions, code.ToString(), errorLogger, cancellationToken)); } }
/// <summary> /// Returns a <see cref="SourceText"/> with the contents of this file, or <c>null</c> if /// there were errors reading the file. /// </summary> public override SourceText GetText(CancellationToken cancellationToken = default) { lock (_lockObject) { if (_text == null) { var diagnostics = new List <DiagnosticInfo>(); _text = _compiler.TryReadFileContent(_sourceFile, diagnostics); _diagnostics = diagnostics; } } return(_text); }