Skip to content

Commit e516e3b

Browse files
committed
Comments from copilot round 1
1 parent c0127ec commit e516e3b

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/Utilities/AsyncHelper.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,9 +768,11 @@ private static void ObserveContinuationException(Task continuationTask)
768768
static task =>
769769
{
770770
SqlClientEventSource.Log.TryTraceEvent($"Unobserved task exception: {task.Exception}");
771-
return _ = task.Exception;
771+
_ = task.Exception;
772772
},
773-
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously);
773+
CancellationToken.None,
774+
TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously,
775+
TaskScheduler.Default);
774776
}
775777

776778
private record ContinuationState(

src/Microsoft.Data.SqlClient/tests/UnitTests/Microsoft/Data/SqlClient/Utilities/AsyncHelperTest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,9 +1304,13 @@ public void WaitForCompletion_DoesNotCreateUnobservedException()
13041304
onTimeout: null,
13051305
rethrowExceptions: true);
13061306

1307+
// - Task has timed out, simulate faulting task completion source
1308+
tcs.SetException(new Exception("late failure"));
1309+
13071310
// - Force collection of unobserved task
13081311
GC.Collect();
13091312
GC.WaitForPendingFinalizers();
1313+
GC.Collect();
13101314

13111315
// Assert
13121316
// - Make sure no unobserved tasks happened

0 commit comments

Comments
 (0)