Repository navigation
[release/11.0.1xx] Prevent CA2025 analyzer crash for direct field arguments - #56340
Merged
tannergooding merged 3 commits intoSep 21, 2026
Merged
Conversation
Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
Cover field, property, and method-returned StreamReader arguments in both C# and Visual Basic. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
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. |
artl93
approved these changes
Sep 17, 2026
artl93
left a comment
Member
There was a problem hiding this comment.
Customer reported. Regression. Analyzers should not crash. Approved for me.
This was referenced Sep 21, 2026
This was referenced Oct 26, 2026
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.
Backport of #55904 to release/11.0.1xx
Fixes #53926
RC2 backport approval has been obtained;
servicing-approvedstill needs to be recorded on this PR.Customer Impact
When CA2025 is enabled, passing a non-local disposable argument to a task-returning invocation, awaiting the task later, and analyzing disposal in the same method can crash the analyzer with
NullReferenceException/AD0001. This interrupts analysis and can fail warnings-as-errors builds. The backport removes the analyzer crash; it does not address an application crash or enable this opt-in rule.Regression
The issue investigation reports reproduction with .NET 10 and .NET 11, with .NET 9 as a negative control. This is an existing prior-release regression, not a newly introduced .NET 11 rule.
Testing
Includes
NonLocalArgumentsAwaitedElsewhereBeforeDispose_NoDiagnosticAsync, covering field, property, and method-result arguments in both C# and Visual Basic, followed by delayed awaits and disposal. The final source diff and included coverage were inspected; the backport workflow completed successfully. Release-branch test results remain pending and are not implied by successful backport creation.Risk
Low. The change filters null entries from the existing local-reference extraction helper. Converted and unconverted local references retain their existing handling. Non-local arguments were already unsupported by this tracking path; filtering them removes the exception rather than removing working field/property analysis. No diagnostic severity, default enablement, or new field-analysis support is introduced.
Note
This PR description was drafted with GitHub Copilot.