Skip to content

MA0011: do not bind the invocations of attribute arguments speculatively - #1709

Merged
meziantou merged 1 commit into
mainfrom
feature/fuzz-ma0011-attribute-argument
Oct 18, 2026
Merged

meziantou merged 1 commit into
mainfrom
feature/fuzz-ma0011-attribute-argument

Conversation

@meziantou

Copy link
Copy Markdown
Owner

Fixes #1686

ArgumentListHelper binds the new invocation speculatively to check the overload it calls. For an invocation in an attribute argument, Roslyn threw NullReferenceException in the binder ([assembly:(string.Format("", new object[] { -1, a is g System }) with top-level statements).

An attribute argument must be a constant (CS0182), so an invocation can never be one. ArgumentListHelper no longer binds the invocations in an attribute argument, so the code fixes that use it (MA0011, and the ones that add a StringComparison, CancellationToken, MidpointRounding, or TimeProvider argument) are not offered there.

Tests

Regression tests for each issue, using the fuzz inputs reduced to the code that reproduces them. The fuzz inputs no longer reproduce with dotnet run --project tests/Meziantou.Analyzer.Fuzz -c Release -- repro. The whole test suite passes on all the Roslyn versions.

@meziantou
meziantou merged commit 81ca3ce into main Oct 18, 2026
14 checks passed
@meziantou
meziantou deleted the feature/fuzz-ma0011-attribute-argument branch October 18, 2026 17:11
This was referenced Oct 18, 2026
This was referenced Oct 24, 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.

[Fuzzing] MA0011 (UseIFormatProviderFixer) throws NullReferenceException in BindingContext.GetTargetMethod

1 participant