@@ -80,11 +80,6 @@ public void Execute(IExecutionContext context, Command command)
8080
8181 TestRunContext runContext = CreateTestRunContext ( ) ;
8282
83- // Capture all mutable instance state as locals before the async continuation.
84- // The command lock (_commandSerializeLock in WorkerCommandManager) releases when
85- // Execute() returns, but the async task continues running. A subsequent Execute()
86- // call would overwrite these instance fields, causing the in-flight async task to
87- // read corrupted state. Capturing as locals makes the async task self-contained.
8883 var executionContext = _executionContext ;
8984 var testResultFiles = _testResultFiles ;
9085 var testRunner = _testRunner ;
@@ -386,12 +381,12 @@ private async Task PublishTestRunDataAsync(
386381 }
387382
388383 // Queue code coverage merge job if code coverage attachments are published to avoid BQC timeout.
389- private void TriggerCoverageMergeJob ( List < string > resultFilesInput , IExecutionContext executionContext )
384+ private void TriggerCoverageMergeJob ( List < string > resultFilesInput , IExecutionContext context )
390385 {
391386 try
392387 {
393- ITestResultsServer _testResultsServer = executionContext . GetHostContext ( ) . GetService < ITestResultsServer > ( ) ;
394- using ( var connection = WorkerUtilities . GetVssConnection ( executionContext ) )
388+ ITestResultsServer _testResultsServer = context . GetHostContext ( ) . GetService < ITestResultsServer > ( ) ;
389+ using ( var connection = WorkerUtilities . GetVssConnection ( context ) )
395390 {
396391 foreach ( var resultFile in resultFilesInput )
397392 {
@@ -411,14 +406,14 @@ private void TriggerCoverageMergeJob(List<string> resultFilesInput, IExecutionCo
411406 Path . GetExtension ( file ) . Equals ( ".coverage" , StringComparison . OrdinalIgnoreCase )
412407 )
413408 {
414- _testResultsServer . InitializeServer ( connection , executionContext ) ;
409+ _testResultsServer . InitializeServer ( connection , context ) ;
415410 try
416411 {
417- var codeCoverageResults = _testResultsServer . UpdateCodeCoverageSummaryAsync ( connection , executionContext . Variables . System_TeamProjectId . ToString ( ) , executionContext . Variables . Build_BuildId . GetValueOrDefault ( ) ) ;
412+ var codeCoverageResults = _testResultsServer . UpdateCodeCoverageSummaryAsync ( connection , context . Variables . System_TeamProjectId . ToString ( ) , context . Variables . Build_BuildId . GetValueOrDefault ( ) ) ;
418413 }
419414 catch ( Exception e )
420415 {
421- executionContext . Section ( $ "Could not queue code coverage merge:{ e } ") ;
416+ context . Section ( $ "Could not queue code coverage merge:{ e } ") ;
422417 }
423418 }
424419 }
@@ -428,7 +423,7 @@ private void TriggerCoverageMergeJob(List<string> resultFilesInput, IExecutionCo
428423 }
429424 catch ( Exception e )
430425 {
431- executionContext . Debug ( $ "Exception in Method:{ e . Message } ") ;
426+ context . Debug ( $ "Exception in Method:{ e . Message } ") ;
432427 }
433428 }
434429
0 commit comments