[RuntimeAsync] make a test compatible with runtime async.#120701
Merged
VSadov merged 2 commits intodotnet:mainfrom Oct 15, 2025
Merged
[RuntimeAsync] make a test compatible with runtime async.#120701VSadov merged 2 commits intodotnet:mainfrom
VSadov merged 2 commits intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR modifies a test to be compatible with runtime async by handling cases where no active task tracking exists. The test was previously assuming that s_currentActiveTasks would always be initialized when async code runs, but runtime async doesn't create tasks on the synchronous/fast path, making this assumption invalid.
- Updated test to handle null
s_currentActiveTasksfield - Added null check before accessing the Count property
- Maintained the original assertion logic when active tasks do exist
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| testOut5.txt | Tool restoration output log (not relevant to the code change) |
| AsyncTaskMethodBuilderTests.cs | Added null check for s_currentActiveTasks field before accessing its Count property |
.../System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTests.cs
Outdated
Show resolved
Hide resolved
jkoritzinsky
approved these changes
Oct 15, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This is a test-only change.
The particular testcase looks into implementation details of active task tracking like
s_currentActiveTasksRuntime async does not have task tracking on synchronous/fast path since no tasks are created, so assumption that as long as we have async code,
s_currentActiveTaskswill be initialized to something is no longer true.Test expects "fewer than 10 active tasks" at the end of the scenario.
I changed the test to handle a case if no active tasks were tracked at all. This keeps the test checking for the same thing - that not a lot of active tasks may hang around unexpectedly, but avoids a crash if
s_currentActiveTasksisnull.