Add missing code fixers for 10 analyzer rules#1073
Merged
Conversation
…A0059, MA0062, MA0063, MA0082, and MA0087 Implement missing code fix providers for the requested diagnostics, extend OptimizeLinqUsageFixer for MA0063, and add tests/docs updates for the new fixes. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove dead helper and simplify operand selection logic to avoid IDE0051/IDE0059 failures in CI. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use attribute constructor symbol to map GeneratedRegex attribute arguments by parameter so the RegexOptions argument is correctly identified with roslyn4.2/4.4. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add DoNotNaN tests for double/float/Half, update Half handling in the fixer, and update MA0023 fixer to produce simplifiable RegexOptions.ExplicitCapture output with corresponding test expectations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
meziantou
commented
Mar 30, 2026
Allow MA0011 analyzer/fixer to use overloads with optional parameters, add tests for non-last IFormatProvider and named argument insertion, and resolve Half via compilation metadata in the NaN fixer. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Show InvariantCulture first in UseIFormatProviderFixer and update MA0011 code-fix tests to validate both offered fixes by index while keeping the default fix aligned with the first suggestion. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 31, 2026
Closed
Closed
Closed
This was referenced Apr 12, 2026
Open
This was referenced Apr 19, 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.
Summary
This PR adds missing code fix support for a set of existing analyzer rules so users can apply fixes directly from diagnostics instead of addressing them manually.
It implements code fix providers for the requested rules, extends an existing LINQ fixer for
MA0063, and updates rule tests and generated documentation accordingly.What changed
UseIFormatProviderFixer(MA0011)UseRegexExplicitCaptureOptionsFixer(MA0023)EmbedCaughtExceptionAsInnerExceptionFixer(MA0054)TypeNameShouldEndWithSuffixFixer(MA0057,MA0058,MA0059)NonFlagsEnumsShouldNotBeMarkedWithFlagsAttributeFixer(MA0062)DoNotNaNInComparisonsFixer(MA0082)OptimizeLinqUsageFixerto supportMA0063(reorderWherebefore ordering operations).OptionalParametersAttributeFixerto support both optional-attribute diagnostics paths (MA0087andMA0088) after merging with latestmainchanges.README.md,docs/README.md, and affecteddocs/Rules/MAxxxx.mdfiles).DocumentationGeneratorroot detection to work in git worktrees by accepting.gitas directory or file.Validation
dotnet build Meziantou.Analyzer.slnxdotnet test Meziantou.Analyzer.slnxdotnet test Meziantou.Analyzer.slnx --filter "FullyQualifiedName~OptionalParametersAttributeAnalyzerMA0087Tests|FullyQualifiedName~OptionalParametersAttributeAnalyzerMA0088Tests"dotnet run --project src/DocumentationGenerator(re-run until clean)Notes for reviewers
MA0063support was added to an existing shared LINQ fixer rather than a separate provider to keep behavior aligned with existing LINQ transforms.OptionalParametersAttributeFixernow handles bothMA0087andMA0088so both diagnostic paths have matching fixes after recent upstream changes.