Skip to content

Fix MA0003 Fix All producing invalid named-argument rewrites in multi-argument calls#1168

Merged
meziantou merged 3 commits into
mainfrom
copilot/fix-ma0003-auto-code-fix
May 21, 2026
Merged

Fix MA0003 Fix All producing invalid named-argument rewrites in multi-argument calls#1168
meziantou merged 3 commits into
mainfrom
copilot/fix-ma0003-auto-code-fix

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

MA0003’s code fix could misapply parameter names when multiple arguments in the same invocation were fixed together, producing invalid syntax by stacking name colons onto one argument. This updates Fix All behavior to apply argument naming deterministically per diagnostic span.

  • Fix All behavior for MA0003

    • Introduced a dedicated NamedParameterFixAllProvider for NamedParameterFixer.
    • Applies diagnostics in descending source order to avoid span-shift/collision while rewriting arguments in the same call site.
    • Replaces reliance on WellKnownFixAllProviders.BatchFixer for this rule.
  • Fixer refactor for span-driven application

    • Reused the same argument-name insertion path from both single-fix and fix-all flows.
    • Switched to span-based argument lookup so each diagnostic maps to the intended ArgumentSyntax after prior edits.
  • Regression coverage

    • Added BatchFix_MultipleArgumentsInSingleInvocation to NamedParameterAnalyzerTests.
    • Covers the reported shape where several unnamed null arguments in one invocation must all be named.
// Before batch fix (multiple MA0003 diagnostics on same invocation)
this.InsertStatus(null, null, null, utcStatuses: null, null);

// After
this.InsertStatus(
    reviewStatuses: null,
    courseStatuses: null,
    paymentInfos: null,
    utcStatuses: null,
    dmvStatuses: null);

Copilot AI linked an issue May 21, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits May 21, 2026 15:10
Co-authored-by: meziantou <509220+meziantou@users.noreply.github.com>
Co-authored-by: meziantou <509220+meziantou@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issues with MA0003 auto code fix Fix MA0003 Fix All producing invalid named-argument rewrites in multi-argument calls May 21, 2026
Copilot AI requested a review from meziantou May 21, 2026 15:14
@meziantou meziantou marked this pull request as ready for review May 21, 2026 15:44
@meziantou meziantou merged commit 11bc5ad into main May 21, 2026
13 checks passed
@meziantou meziantou deleted the copilot/fix-ma0003-auto-code-fix branch May 21, 2026 15:53
IhateTrains pushed a commit to ParadoxGameConverters/ImperatorToCK3 that referenced this pull request May 22, 2026
Updated
[Meziantou.Analyzer](https://github.com/meziantou/Meziantou.Analyzer)
from 3.0.90 to 3.0.91.

<details>
<summary>Release notes</summary>

_Sourced from [Meziantou.Analyzer's
releases](https://github.com/meziantou/Meziantou.Analyzer/releases)._

## 3.0.91

NuGet package:
<https://www.nuget.org/packages/Meziantou.Analyzer/3.0.91>

## What's Changed
* Fix MA0003 Fix All producing invalid named-argument rewrites in
multi-argument calls by @​Copilot in
meziantou/Meziantou.Analyzer#1168


**Full Changelog**:
meziantou/Meziantou.Analyzer@3.0.90...3.0.91

Commits viewable in [compare
view](meziantou/Meziantou.Analyzer@3.0.90...3.0.91).
</details>

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=Meziantou.Analyzer&package-manager=nuget&previous-version=3.0.90&new-version=3.0.91)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This was referenced May 22, 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.

Issues with MA0003 auto code fix

2 participants