Skip to content

Fix VSTHRD200 handling of custom awaitables - #1644

Merged
Andrew Arnott (AArnott) merged 1 commit into
mainfrom
aarnott-fix-vsthrd200-awaitables
Aug 22, 2026
Merged

Andrew Arnott (AArnott) merged 1 commit into
mainfrom
aarnott-fix-vsthrd200-awaitables

Conversation

@AArnott

Copy link
Copy Markdown
Member

VSTHRD200 can incorrectly reject the Async suffix for derived awaitable types, while libraries have no way to identify custom types that should require the suffix.

This change makes awaitable detection inheritance-aware and adds vs-threading.AsyncSuffixRequiredTypes.txt configuration for opt-in async-focused return types. The shared awaitable detection improvement also covers VSTHRD110. Documentation and regression coverage are included.

Fixes #419
Fixes #1023

Fixes #419
Fixes #1023

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 21, 2026 15:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves analyzer handling of custom awaitables by making awaitable detection inheritance-aware (fixing false positives for derived awaitables) and by adding an opt-in additional-file configuration to require the Async suffix for library-specific async-focused return types.

Changes:

  • Extend CommonInterest.AwaitableTypeTester to recognize awaitable types via base classes and implemented interfaces (covers VSTHRD200 and VSTHRD110 usage).
  • Add vs-threading.AsyncSuffixRequiredTypes.txt support to VSTHRD200 so libraries can opt-in custom return types that must use the Async suffix.
  • Add regression tests and documentation for the new behavior and configuration.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD200UseAsyncNamingConventionAnalyzerTests.cs Adds coverage for derived-awaitable returns and for the new async-suffix-required type configuration.
test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD110ObserveResultOfAsyncCallsAnalyzerTests.cs Adds a regression test ensuring derived custom awaitables still produce diagnostics as expected.
test/Microsoft.VisualStudio.Threading.Analyzers.Tests/AdditionalFiles/vs-threading.AsyncSuffixRequiredTypes.mocks.txt Provides a mocked additional-file entry to exercise the new VSTHRD200 configuration path in tests.
src/Microsoft.VisualStudio.Threading.Analyzers/VSTHRD200UseAsyncNamingConventionAnalyzer.cs Reads configured async-suffix-required types and incorporates them into “async-focused return type” detection.
src/Microsoft.VisualStudio.Threading.Analyzers/CommonInterest.cs Adds the new additional-file name pattern and updates awaitable detection to be inheritance-aware.
docfx/analyzers/VSTHRD200.md Documents that custom async-focused return types can be configured to require the suffix.
docfx/analyzers/configuration.md Adds documentation for vs-threading.AsyncSuffixRequiredTypes.txt format and usage.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@AArnott
Andrew Arnott (AArnott) merged commit 6450723 into main Aug 22, 2026
10 checks passed
@AArnott
Andrew Arnott (AArnott) deleted the aarnott-fix-vsthrd200-awaitables branch August 22, 2026 03:06
This was referenced Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

VSTHRD200 should consider derived type of awaitable type as awaitable Add AdditionalFiles for types that VSTHRD200 should require an Async suffix for

3 participants