private void RaiseUpdateOutputWindow(string reportFilePath) { UpdateOutputWindowEventArgs updateOutputWindowEventArgs = new UpdateOutputWindowEventArgs { }; try { if (!string.IsNullOrEmpty(reportFilePath)) { var htmlContent = File.ReadAllText(reportFilePath); updateOutputWindowEventArgs.HtmlContent = htmlContent; } } catch { logger.Log(errorReadingReportGeneratorOutputMessage); } finally { UpdateOutputWindow?.Invoke(updateOutputWindowEventArgs); } }
private static void ReloadCoverage(List <CoverageProject> projects) { Logger.Log("================================== START =================================="); Reset(); var coverageTask = System.Threading.Tasks.Task.Run(async() => { // process pipeline await PrepareCoverageProjectsAsync(projects); foreach (var project in projects) { cancellationToken.ThrowIfCancellationRequested(); await project.StepAsync("Run Coverage Tool", RunCoverToolAsync); } var passedProjects = projects.Where(x => !x.HasFailed); var coverOutputFiles = passedProjects .Select(x => x.CoverageOutputFile) .ToArray(); if (coverOutputFiles.Any()) { cancellationToken.ThrowIfCancellationRequested(); // run reportGenerator process var darkMode = CurrentTheme.Equals("Dark", StringComparison.OrdinalIgnoreCase); var result = await ReportGeneratorUtil.RunReportGeneratorAsync(coverOutputFiles, darkMode, true); if (result.Success) { // update CoverageLines CoverageReport = CoberturaUtil.ProcessCoberturaXmlFile(result.UnifiedXmlFile, out var coverageLines); CoverageLines = coverageLines; // update HtmlFilePath ReportGeneratorUtil.ProcessUnifiedHtmlFile(result.UnifiedHtmlFile, darkMode, out var htmlFilePath); HtmlFilePath = htmlFilePath; } // update margins { UpdateMarginTagsEventArgs updateMarginTagsEventArgs = null; try { updateMarginTagsEventArgs = new UpdateMarginTagsEventArgs { }; } catch { // ignore } finally { UpdateMarginTags?.Invoke(updateMarginTagsEventArgs); } } // update output window { UpdateOutputWindowEventArgs updateOutputWindowEventArgs = null; try { if (!string.IsNullOrEmpty(HtmlFilePath)) { updateOutputWindowEventArgs = new UpdateOutputWindowEventArgs { HtmlContent = File.ReadAllText(HtmlFilePath) }; } } catch { // ignore } finally { UpdateOutputWindow?.Invoke(updateOutputWindowEventArgs); } } } // log Logger.Log("================================== DONE ==================================="); cancellationTokenSource.Dispose(); cancellationTokenSource = null; }, cancellationToken); }