Repository navigation
Exclude MemoryStream operations from VSTHRD103 - #1702
Andrew Arnott (AArnott) with Copilot wants to merge 8 commits into
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
Co-authored-by: AArnott <3548+AArnott@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
🟡 Changes recommended
Receiver-type exclusions are bypassed for known blocking methods, and the new Read test passes without exercising the exclusion because its enclosing method is named ReadAsync.
2 open issues
What changed in this PR
Adds built-in VSTHRD103 exemptions for synchronous MemoryStream operations, addressing #1699 while preserving diagnostics for Stream-typed receivers.
Changes:
- Exclude
Read,Write,Flush,CopyTo, andDisposeby default. - Extend instance-method exclusion matching to the receiver’s static type.
- Add regression coverage and document the defaults, including the risk of blocking I/O at
CopyTodestinations.
| File | Description |
|---|---|
test/Microsoft.VisualStudio.Threading.Analyzers.Tests/VSTHRD103UseAsyncOptionAnalyzerTests.cs |
Adds coverage for overloads, conditional access, and Stream-typed calls. |
src/Microsoft.VisualStudio.Threading.Analyzers.CSharp/VSTHRD103UseAsyncOptionAnalyzer.cs |
Adds receiver-type matching to exclusion checks. |
src/Microsoft.VisualStudio.Threading.Analyzers.CodeFixes/buildTransitive/AdditionalFiles/vs-threading.SyncMethodsToExcludeFromVSTHRD103.frameworks.txt |
Packages the five default MemoryStream exclusions. |
docfx/analyzers/VSTHRD103.md |
Explains the exemption and the CopyTo destination caveat. |
docfx/analyzers/configuration.md |
Documents receiver matching and lists the new defaults. |
Review effort: Balanced
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
|
Copilot respond to the code review feedback. |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
The added test passes through the existing declaring-type check, so it does not protect the new receiver-type matching against regression and should exclude Task`1 instead.
1 open issue
2 resolved since last review
Review effort: Balanced
|
One or more custom setup steps configured for this repository failed during this Copilot code review run: Setup steps run before each review. If the review above is missing context, or no review was posted at all, the failing step above may be the cause. See the workflow run for failure details, fix your setup steps configuration, and re-request a review. Note You can configure setup steps for Copilot code review separately from Copilot cloud agent with a |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). |
…-memorystream-operations Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>

VSTHRD103 recommends async alternatives for synchronous
MemoryStreamoperations, where accessing in-memory data needs no async machinery. These APIs should be exempt by default rather than requiring per-project configuration.Read,Write,Flush,CopyTo, andDispose.Stream-typed receivers.Stream-typed calls. Document the defaults and note thatCopyTodestinations may still perform blocking I/O.