Repository navigation
Tests: Replace WhenAny/Delay timeouts with WaitOrTimeoutAsync - #141
Merged
Merged
Conversation
Microsoft.CodeAnalysis.NetAnalyzers 11 adds CA2027, which flags Task.WhenAny(task, Task.Delay(...)) because the delay timer keeps running after the task completes. dotnet format reports it, which fails the format check in CI (Dependabot PR #139). Add a WaitOrTimeoutAsync test helper built on Task.WaitAsync that returns false on timeout instead of throwing, so the timing-tolerant pause tests keep their current behavior, and use it at all 12 sites.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #141 +/- ##
=======================================
Coverage 78.82% 78.82%
=======================================
Files 44 44
Lines 4874 4874
Branches 726 726
=======================================
Hits 3842 3842
Misses 775 775
Partials 257 257 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Dependabot PR #139 bumps
Microsoft.CodeAnalysis.NetAnalyzersto 11.0.100, which adds CA2027:Task.WhenAny(task, Task.Delay(...))leaves the delay timer running after the task completes.dotnet format --verify-no-changesreports it, so the format check fails (12 warnings, all in tests).What
WaitOrTimeoutAsync(timeout)intests/SharpSync.Tests/Fixtures/TaskExtensions.cs, built onTask.WaitAsync. It returnsfalseon timeout instead of throwing, so the timing-tolerant pause tests keep their current behavior.WhenAny/Delaysites inSyncEngineTests,SyncEngineEdgeCaseTestsandSyncEngineThreadSafetyTestsnow use it. The unusedpauseOrTimeoutvariables are gone.Verification
dotnet test: 819 passed, 0 failed, 130 integration tests skipped.dotnet format --verify-no-changespasses with NetAnalyzers 10.0.403 and with 11.0.100 swapped in locally.After merging,
@dependabot rebaseon #139 should turn it green.