@@ -22,7 +22,6 @@ internal class FCCEngine : IFCCEngine
2222 {
2323 internal int InitializeWait { get ; set ; } = 5000 ;
2424 internal const string initializationFailedMessagePrefix = "Initialization failed. Please check the following error which may be resolved by reopening visual studio which will start the initialization process again." ;
25- internal const string errorReadingReportGeneratorOutputMessage = "error reading report generator output" ;
2625 private readonly object colorThemeService ;
2726 private string CurrentTheme => $ "{ ( ( dynamic ) colorThemeService ) ? . CurrentTheme ? . Name } ". Trim ( ) ;
2827
@@ -44,6 +43,7 @@ internal class FCCEngine : IFCCEngine
4443 private readonly IAppDataFolder appDataFolder ;
4544 private readonly IServiceProvider serviceProvider ;
4645 private IInitializeStatusProvider initializeStatusProvider ;
46+ private readonly ICoverageToolOutputManager coverageOutputManager ;
4747 internal System . Threading . Tasks . Task reloadCoverageTask ;
4848
4949 [ ImportingConstructor ]
@@ -56,10 +56,12 @@ public FCCEngine(
5656 IAppOptionsProvider appOptionsProvider ,
5757 ILogger logger ,
5858 IAppDataFolder appDataFolder ,
59+ ICoverageToolOutputManager coverageOutputManager ,
5960 [ Import ( typeof ( SVsServiceProvider ) ) ]
6061 IServiceProvider serviceProvider
6162 )
6263 {
64+ this . coverageOutputManager = coverageOutputManager ;
6365 this . coverageUtilManager = coverageUtilManager ;
6466 this . coberturaUtil = coberturaUtil ;
6567 this . msTestPlatformUtil = msTestPlatformUtil ;
@@ -142,54 +144,38 @@ private async System.Threading.Tasks.Task<string[]> RunCoverageAsync(List<ICover
142144
143145 }
144146
145- private void RaiseUpdateOutputWindow ( string reportFilePath )
147+ private void RaiseUpdateOutputWindow ( string reportHtml )
146148 {
147- UpdateOutputWindowEventArgs updateOutputWindowEventArgs = new UpdateOutputWindowEventArgs { } ;
148-
149- try
150- {
151- if ( ! string . IsNullOrEmpty ( reportFilePath ) )
152- {
153- var htmlContent = File . ReadAllText ( reportFilePath ) ;
154- updateOutputWindowEventArgs . HtmlContent = htmlContent ;
155- }
156- }
157- catch
158- {
159- logger . Log ( errorReadingReportGeneratorOutputMessage ) ;
160- }
161- finally
162- {
163- UpdateOutputWindow ? . Invoke ( updateOutputWindowEventArgs ) ;
164- }
149+ UpdateOutputWindowEventArgs updateOutputWindowEventArgs = new UpdateOutputWindowEventArgs { HtmlContent = reportHtml } ;
150+ UpdateOutputWindow ? . Invoke ( updateOutputWindowEventArgs ) ;
165151 }
166- private void UpdateUI ( List < CoverageLine > coverageLines , string reportFilePath )
152+ private void UpdateUI ( List < CoverageLine > coverageLines , string reportHtml )
167153 {
168154 CoverageLines = coverageLines ;
169155 UpdateMarginTags ? . Invoke ( new UpdateMarginTagsEventArgs ( ) ) ;
170- RaiseUpdateOutputWindow ( reportFilePath ) ;
156+ RaiseUpdateOutputWindow ( reportHtml ) ;
171157 }
172158
173159 private async System . Threading . Tasks . Task < ( List < CoverageLine > coverageLines , string reportFilePath ) > RunAndProcessReportAsync ( string [ ] coverOutputFiles , CancellationToken cancellationToken )
174160 {
175161 cancellationToken . ThrowIfCancellationRequested ( ) ;
176162
177163 List < CoverageLine > coverageLines = null ;
178- string reportFilePath = null ;
164+ string processedReport = null ;
179165
180166 var darkMode = CurrentTheme . Equals ( "Dark" , StringComparison . OrdinalIgnoreCase ) ;
181167
182168 var result = await reportGeneratorUtil . RunReportGeneratorAsync ( coverOutputFiles , darkMode , true ) ;
183169
184170 if ( result . Success )
185171 {
186- coberturaUtil . ProcessCoberturaXmlFile ( result . UnifiedXmlFile ) ;
172+ coberturaUtil . ProcessCoberturaXml ( result . UnifiedXml ) ;
187173 coverageLines = coberturaUtil . CoverageLines ;
188174
189- reportGeneratorUtil . ProcessUnifiedHtmlFile ( result . UnifiedHtmlFile , darkMode , out var htmlFilePath ) ;
190- reportFilePath = htmlFilePath ;
175+ processedReport = reportGeneratorUtil . ProcessUnifiedHtml ( result . UnifiedHtml , darkMode ) ;
176+ coverageOutputManager . SetReportOutput ( result . UnifiedHtml , processedReport , result . UnifiedXml ) ;
191177 }
192- return ( coverageLines , reportFilePath ) ;
178+ return ( coverageLines , processedReport ) ;
193179 }
194180
195181 private async System . Threading . Tasks . Task PrepareCoverageProjectsAsync ( List < ICoverageProject > coverageProjects , CancellationToken cancellationToken )
@@ -213,7 +199,7 @@ private async System.Threading.Tasks.Task PrepareCoverageProjectsAsync(List<ICov
213199 }
214200 }
215201
216- private void ReloadCoverageTaskContinuation ( System . Threading . Tasks . Task < ( List < CoverageLine > coverageLines , string reportFilePath ) > t )
202+ private void ReloadCoverageTaskContinuation ( System . Threading . Tasks . Task < ( List < CoverageLine > coverageLines , string reportHtml ) > t )
217203 {
218204 switch ( t . Status )
219205 {
@@ -228,7 +214,7 @@ private void ReloadCoverageTaskContinuation(System.Threading.Tasks.Task<(List<Co
228214 case System . Threading . Tasks . TaskStatus . RanToCompletion :
229215 LogReloadCoverageStatus ( ReloadCoverageStatus . Done ) ;
230216#pragma warning disable VSTHRD002 // Avoid problematic synchronous waits
231- UpdateUI ( t . Result . coverageLines , t . Result . reportFilePath ) ;
217+ UpdateUI ( t . Result . coverageLines , t . Result . reportHtml ) ;
232218#pragma warning restore VSTHRD002 // Avoid problematic synchronous waits
233219 break ;
234220 }
@@ -263,24 +249,26 @@ public void ReloadCoverage(Func<System.Threading.Tasks.Task<List<ICoverageProjec
263249 reloadCoverageTask = System . Threading . Tasks . Task . Run ( async ( ) =>
264250 {
265251 List < CoverageLine > coverageLines = null ;
266- string reportFilePath = null ;
252+ string reportHtml = null ;
267253
268254 await PollInitializedStatusAsync ( cancellationToken ) ;
269255
270256 LogReloadCoverageStatus ( ReloadCoverageStatus . Start ) ;
271257
272258 var coverageProjects = await coverageRequestCallback ( ) ;
273259
260+ coverageOutputManager . SetProjectCoverageOutputFolder ( coverageProjects ) ;
261+
274262 var coverOutputFiles = await RunCoverageAsync ( coverageProjects , cancellationToken ) ;
275263
276264 if ( coverOutputFiles . Any ( ) )
277265 {
278- var ( lines , rFilePath ) = await RunAndProcessReportAsync ( coverOutputFiles , cancellationToken ) ;
266+ var ( lines , report ) = await RunAndProcessReportAsync ( coverOutputFiles , cancellationToken ) ;
279267 coverageLines = lines ;
280- reportFilePath = rFilePath ;
268+ reportHtml = report ;
281269 }
282270
283- return ( coverageLines , reportFilePath ) ;
271+ return ( coverageLines , reportHtml ) ;
284272
285273 } , cancellationToken )
286274 . ContinueWith ( t =>
0 commit comments