Repository navigation
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Co-authored-by: nagilson <23152278+nagilson@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix CA2025 analyzer crash with NRE during compilation
Add CA2025 regression coverage for tuple-state task races
Nov 5, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the regression-test and cancellation-token changes.
No open issues 🎉
What changed in this PR
Adds regression coverage for the CA2025 analyzer crash scenario reported in #56540, guarding the existing fix without changing analyzer behavior or adding the .NET 10 servicing fix.
Changes:
- Adds a no-diagnostic test combining tuple-state
Task.Factory.StartNew, non-local disposable arguments,Task.WhenAny, and subsequentforeachdisposal. - Adds
TestContextto pass the test cancellation token to the analyzer test harness.
| File | Description |
|---|---|
| src/Microsoft.CodeAnalysis.NetAnalyzers/tests/Microsoft.CodeAnalysis.NetAnalyzers.UnitTests/Microsoft.CodeQuality.Analyzers/QualityGuidelines/DoNotPassDisposablesIntoUnawaitedTasksTests.cs | Adds the tuple-state task-race regression test and cancellation-token support. |
Review effort: Balanced
This branch has not been deployed
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.
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
b5ab0d961785ed40448538269d9b39eaa5da93f4↑ All 20
DoNotPassDisposablesIntoUnawaitedTasksTestspass locally after merging current main.↑ New test fails with the exact AD0001
NullReferenceExceptionwhen the main-branch fix (aa287a97031) is locally reverted, so it guards the regression.↓ Fresh CI for this head is pending; earlier run failures (NU1903 in
Microsoft.DotNet.Cli.Run.Testsfor vulnerableMicrosoft.DotNet.ILCompiler11.0.0-preview.7.26381.103) were unrelated and main has since moved to 11.0.0-rc.3.26522.148; the old AzDO build was purged, so not all earlier failures could be inspected.CA2025 could crash when non-local disposable expressions appeared alongside tuple state, competing tasks,
Task.WhenAny, and laterforeachdisposal.Task.Factory.StartNew.main. It does not include the .NET 10 (10.0.4xx) servicing fix requested in the issue;release/10.0.4xxstill contains the unsafedisposableArg.Localaccess.