-
Notifications
You must be signed in to change notification settings - Fork 0
Replace blocking Task operations in tests with ManualResetEventSlim #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: jeanlrnt <[email protected]>
… - MiniCronTests.EventInvocationOutsideLock.cs Co-authored-by: jeanlrnt <[email protected]>
Co-authored-by: jeanlrnt <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses xUnit1031 warnings about potential deadlocks in test methods by replacing TaskCompletionSource<bool> with ManualResetEventSlim for synchronization primitives used in event handler blocking scenarios.
- Replaces
TaskCompletionSource<bool>withManualResetEventSlimin three test methods - Changes blocking calls from
.Task.GetAwaiter().GetResult()to.Wait() - Updates signaling mechanism from
.SetResult(true)to.Set()
|
@copilot apply changes based on the comments in this thread |
…niCronTests.EventInvocationOutsideLock.cs Co-authored-by: jeanlrnt <[email protected]>
Changes applied. Added |
Fix Tests - Remove Blocking Task Operations ✅
Summary
Successfully fixed 3 xUnit1031 warnings about blocking task operations in test methods by replacing
TaskCompletionSource<bool>withManualResetEventSlimfor proper synchronization, and ensured proper disposal.Changes Made
MiniCronTests.EventInvocationOutsideLock.cs:JobRegistry_JobAdded_InvokedOutsideLock_AllowsConcurrentReads(line 16)JobRegistry_JobRemoved_InvokedOutsideLock_AllowsConcurrentReads(line 64)JobRegistry_JobUpdated_InvokedOutsideLock_AllowsConcurrentReads(line 109)TaskCompletionSource<bool>withManualResetEventSlim(false).Task.GetAwaiter().GetResult()to.Wait().SetResult(true)to.Set()usingstatements for proper disposal ofManualResetEventSliminstancesValidation Results
✅ All 155 tests pass in both Debug and Release configurations
✅ Build succeeds with 0 warnings across all target frameworks (.NET 6, 7, 8, 9, 10)
✅ No code review issues identified
✅ No security vulnerabilities detected by CodeQL
✅ Proper resource disposal with using statements
Technical Details
The tests verify that event handlers run outside the lock to allow concurrent reads.
ManualResetEventSlimimplementsIDisposableand is now properly disposed usingusingstatements, ensuring unmanaged resources are released correctly.Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.