public async Task <BuildingResult> DebugAsync(BuildingTask buildingTask) { CheckDisposed(); if (buildingTask is null) { throw new ArgumentNullException(nameof(buildingTask)); } var assemblyName = buildingTask.ProjectName; var sourceCode = buildingTask.SourceCode; if (string.IsNullOrWhiteSpace(assemblyName) || string.IsNullOrWhiteSpace(sourceCode)) { throw new InvalidOperationException(ErrorConstants.MissingParametersMessage); } _sourceText = SourceText.From(sourceCode); using var sw = new StringWriter(); Console.SetOut(sw); Console.SetError(sw); _nextBreakpoint = NextBreakpoint(buildingTask); var debuggingContext = CreateDebuggingContext(); await _debugger.DebugAsync(debuggingContext); _debuggerState = debuggingContext.DebuggingState; _currentLine = debuggingContext.CurrentLine; if (_currentLine == _sourceText.Lines.Count) { Reset(); } return(new BuildingResult { Success = true, CurrentLine = _currentLine, ResultMessage = sw.ToString() }); }