Repository navigation
Fix VSTHRD200 misfiring on methods returning IAsyncEnumerator<T> - #1613
Merged
Merged
Conversation
… type Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix VSTHRD200 mis-fires on async methods returning IAsyncEnumerator
Fix VSTHRD200 misfiring on methods returning IAsyncEnumerator<T>
Jul 8, 2026
Andrew Arnott (AArnott)
approved these changes
Jul 8, 2026
There was a problem hiding this comment.
Pull request overview
This PR fixes the VSTHRD200 async naming analyzer so that methods returning IAsyncEnumerator<T> are treated as “async-focused” return types, eliminating incorrect “remove Async suffix” suggestions and restoring the expected “add Async suffix” diagnostic behavior.
Changes:
- Extend
Utils.IsAsyncCompatibleReturnTypeto recognizeSystem.Collections.Generic.IAsyncEnumerator<T>alongsideIAsyncEnumerable<T>. - Add VSTHRD200 test coverage to ensure methods returning
IAsyncEnumerator<T>require theAsyncsuffix and don’t warn when the suffix is present.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Microsoft.VisualStudio.Threading.Analyzers/Utils.cs | Updates async-focused return type detection to include IAsyncEnumerator<T> by name under System.Collections.Generic. |
| test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD200UseAsyncNamingConventionAnalyzerTests.cs | Adds two new tests validating VSTHRD200 diagnostics for IAsyncEnumerator<T> return types (with and without Async suffix). |
Amadeusz Wieczorek (AmadeusW)
approved these changes
Jul 8, 2026
David Kean (davkean)
approved these changes
Jul 8, 2026
This was referenced Oct 26, 2026
Merged
Open
Closed
Bump the dev-minor-patch group with 16 updates
actions-marketplace-validations/macalbert_envilder#47
Open
Open
This was referenced Oct 26, 2026
Open
Open
Open
Bump Microsoft.VisualStudio.Threading.Analyzers from 17.14.15 to 18.12.1
tomokuni/ZenHanConverter#19
Closed
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.
VSTHRD200 incorrectly treated
IAsyncEnumerator<T>as a non-async return type, causing false "remove Async suffix" warnings and missing "add Async suffix" warnings for methods returning it.Changes
Utils.cs— ExtendedIsAsyncCompatibleReturnTypeto recognizeIAsyncEnumerator<T>(in addition toIAsyncEnumerable<T>) as an async-compatible return type. Both live inSystem.Collections.Genericso the check is a simple name OR condition on the existing namespace check.VSTHRD200UseAsyncNamingConventionAnalyzerTests.cs— Added two test cases mirroring the existingIAsyncEnumerable<T>coverage: one confirming a warning is generated without theAsyncsuffix, and one confirming no warning with the suffix.