@@ -70,15 +70,15 @@ IReportGeneratorUtil reportGeneratorUtil
7070 _ = ThreadHelper . JoinableTaskFactory . RunAsync ( taskProvider ) ;
7171 } ;
7272
73- private async System . Threading . Tasks . Task TestExecutionStartingAsync ( IOperation operation )
73+ private void TestExecutionStarting ( IOperation operation )
7474 {
7575 fccEngine . StopCoverage ( ) ;
7676
7777 var settings = appOptionsProvider . Get ( ) ;
7878 if ( ! settings . Enabled )
7979 {
80- await CombinedLogAsync ( "Coverage not collected as FCC disabled." ) ;
81- await reportGeneratorUtil . EndOfCoverageRunAsync ( ) ;
80+ CombinedLog ( "Coverage not collected as FCC disabled." ) ;
81+ reportGeneratorUtil . EndOfCoverageRun ( ) ;
8282 return ;
8383 }
8484 if ( settings . RunInParallel )
@@ -92,17 +92,17 @@ private async System.Threading.Tasks.Task TestExecutionStartingAsync(IOperation
9292 }
9393 else
9494 {
95- await CombinedLogAsync ( "Coverage collected when tests finish. RunInParallel option true for immediate" ) ;
95+ CombinedLog ( "Coverage collected when tests finish. RunInParallel option true for immediate" ) ;
9696 }
9797 }
9898
99- private async System . Threading . Tasks . Task CombinedLogAsync ( string message )
99+ private void CombinedLog ( string message )
100100 {
101- await reportGeneratorUtil . LogCoverageProcessAsync ( message ) ;
101+ reportGeneratorUtil . LogCoverageProcess ( message ) ;
102102 logger . Log ( message ) ;
103103 }
104104
105- private async System . Threading . Tasks . Task TestExecutionFinishedAsync ( IOperation operation )
105+ private void TestExecutionFinished ( IOperation operation )
106106 {
107107 var settings = appOptionsProvider . Get ( ) ;
108108 if ( ! settings . Enabled || settings . RunInParallel )
@@ -112,8 +112,8 @@ private async System.Threading.Tasks.Task TestExecutionFinishedAsync(IOperation
112112 var testOperation = testOperationFactory . Create ( operation ) ;
113113 if ( ! settings . RunWhenTestsFail && testOperation . FailedTests > 0 )
114114 {
115- await CombinedLogAsync ( $ "Skipping coverage due to failed tests. Option { nameof ( AppOptions . RunWhenTestsFail ) } is false") ;
116- await reportGeneratorUtil . EndOfCoverageRunAsync ( ) ;
115+ CombinedLog ( $ "Skipping coverage due to failed tests. Option { nameof ( AppOptions . RunWhenTestsFail ) } is false") ;
116+ reportGeneratorUtil . EndOfCoverageRun ( ) ;
117117 return ;
118118 }
119119
@@ -123,8 +123,8 @@ private async System.Threading.Tasks.Task TestExecutionFinishedAsync(IOperation
123123 {
124124 if ( totalTests <= runWhenTestsExceed )
125125 {
126- await CombinedLogAsync ( $ "Skipping coverage as total tests ({ totalTests } ) <= { nameof ( AppOptions . RunWhenTestsExceed ) } ({ runWhenTestsExceed } )") ;
127- await reportGeneratorUtil . EndOfCoverageRunAsync ( ) ;
126+ CombinedLog ( $ "Skipping coverage as total tests ({ totalTests } ) <= { nameof ( AppOptions . RunWhenTestsExceed ) } ({ runWhenTestsExceed } )") ;
127+ reportGeneratorUtil . EndOfCoverageRun ( ) ;
128128 return ;
129129 }
130130 }
@@ -133,43 +133,40 @@ private async System.Threading.Tasks.Task TestExecutionFinishedAsync(IOperation
133133 private bool cancelling ;
134134 private void OperationState_StateChanged ( object sender , OperationStateChangedEventArgs e )
135135 {
136- RunAsync ( async ( ) =>
136+ try
137137 {
138- try
138+ if ( e . State == TestOperationStates . TestExecutionCanceling )
139139 {
140- if ( e . State == TestOperationStates . TestExecutionCanceling )
141- {
142- cancelling = true ;
143- await CombinedLogAsync ( "Test execution cancelling - running coverage will be cancelled." ) ;
144- await reportGeneratorUtil . EndOfCoverageRunAsync ( ) ; // not necessarily true but get desired result
145- fccEngine . StopCoverage ( ) ;
146- }
147-
148-
149- if ( e . State == TestOperationStates . TestExecutionStarting )
150- {
151- await TestExecutionStartingAsync ( e . Operation ) ;
152- cancelling = false ;
153- }
154-
155- if ( e . State == TestOperationStates . TestExecutionFinished )
156- {
157- await TestExecutionFinishedAsync ( e . Operation ) ;
158- }
159-
160- if ( e . State == TestOperationStates . TestExecutionCancelAndFinished && ! cancelling )
161- {
162- await CombinedLogAsync ( "There has been an issue running tests. See the Tests output window pane." ) ;
163- await reportGeneratorUtil . EndOfCoverageRunAsync ( ) ; // not necessarily true but get desired result
164- fccEngine . StopCoverage ( ) ;
165- }
166-
140+ cancelling = true ;
141+ CombinedLog ( "Test execution cancelling - running coverage will be cancelled." ) ;
142+ reportGeneratorUtil . EndOfCoverageRun ( ) ; // not necessarily true but get desired result
143+ fccEngine . StopCoverage ( ) ;
167144 }
168- catch ( Exception exception )
145+
146+
147+ if ( e . State == TestOperationStates . TestExecutionStarting )
169148 {
170- logger . Log ( "Error processing unit test events" , exception ) ;
149+ TestExecutionStarting ( e . Operation ) ;
150+ cancelling = false ;
171151 }
172- } ) ;
152+
153+ if ( e . State == TestOperationStates . TestExecutionFinished )
154+ {
155+ TestExecutionFinished ( e . Operation ) ;
156+ }
157+
158+ if ( e . State == TestOperationStates . TestExecutionCancelAndFinished && ! cancelling )
159+ {
160+ CombinedLog ( "There has been an issue running tests. See the Tests output window pane." ) ;
161+ reportGeneratorUtil . EndOfCoverageRun ( ) ; // not necessarily true but get desired result
162+ fccEngine . StopCoverage ( ) ;
163+ }
164+
165+ }
166+ catch ( Exception exception )
167+ {
168+ logger . Log ( "Error processing unit test events" , exception ) ;
169+ }
173170
174171 }
175172 }
0 commit comments