Skip to content

feat: NE0001 Fix-All — sequential provider for batch rename/move - #11

Merged
samtrion merged 2 commits into
mainfrom
feat/ne0001-fixall
Aug 3, 2026
Merged

feat: NE0001 Fix-All — sequential provider for batch rename/move#11
samtrion merged 2 commits into
mainfrom
feat/ne0001-fixall

Conversation

@samtrion

@samtrion samtrion commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements a custom FixAllProvider for NE0001 so the IDE can offer "Fix all NE0001 in Document/Project/Solution". Previously GetFixAllProvider() returned null, so every violation had to be fixed one lightbulb at a time.

Why not the default batch fixer

WellKnownFixAllProviders.BatchFixer computes each fix independently against the original document and merges the results as text edits. That fails for NE0001 because:

  1. The fix uses document-level operations (WithDocumentName, AddDocument) that are not text edits and are lost by the batch merge.
  2. Two types in one file each compute their fix against the original file, so merging conflicts instead of yielding "original minus both".

Design

A solution-scoped provider that iterates to a fixed point:

solution → apply fix #1 → re-run analyzer → apply fix #2 → … → until no NE0001 remains
  • Re-resolves diagnostics between steps, so a multi-type file's last remaining type correctly flips from move to rename.
  • Handles Document / Project / Solution scope with deterministic document ordering.
  • Skips the collision case (target name equals the current file) without failing the whole batch.

Tests

End-to-end via a real AdhocWorkspace (FixAllRunner): multi-type file resolution, move-then-rename convergence, project scope across multiple files, collision skip, a no-op case, and the null-argument guard.

Closes #10

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are limited based on label configuration.

🏷️ Required labels (at least one) (1)
  • state:ready for merge

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a22430d5-9911-4b77-be41-a9b23b4de224

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.55319% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.71%. Comparing base (26f0ef5) to head (c343b08).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...er/Maintainability/OneTypePerFileFixAllProvider.cs 92.47% 1 Missing and 6 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
- Coverage   99.08%   97.71%   -1.38%     
==========================================
  Files           7       10       +3     
  Lines         328      525     +197     
  Branches       62      106      +44     
==========================================
+ Hits          325      513     +188     
- Misses          0        1       +1     
- Partials        3       11       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add a custom FixAllProvider for NE0001 that resolves every diagnostic in
scope by applying the existing rename/move fixes sequentially on the
accumulating solution, re-resolving diagnostics between each step.

The default WellKnownFixAllProviders.BatchFixer cannot be used because the
fix relies on solution-level operations (WithDocumentName, AddDocument)
rather than text edits, and because multiple types in one file would produce
overlapping edits that fail to merge. Iterating to a fixed point instead lets
a multi-type file's remaining type flip from "move" to "rename" between
rounds, and skips the unfixable collision case without failing the batch.

- Custom FixAllProvider wired via OneTypePerFileCodeFixProvider.GetFixAllProvider()
- Supports Document, Project and Solution scope with deterministic ordering
- Integration tests: multi-type files, move-then-rename convergence,
  project scope, collision skip, no-op, and null-argument guard

Closes #10
@samtrion
samtrion force-pushed the feat/ne0001-fixall branch from 9df3a60 to 9e64ca9 Compare August 3, 2026 14:39
Exercise the custom fix-all provider from both the unit and integration flags
so its lines are not counted as partials against the patch coverage gate:

- Add an AdhocWorkspace-based fix-all runner to the unit suite and mirror the
  Document/Project scope, convergence, collision-skip, no-op and null-argument
  scenarios there
- Cover the supported-scope enumeration and GetFixAllProvider() wiring in both
  suites, and the solution-scope no-op path
- Drop the unreachable document-null guard in TryFixDocumentAsync (the id is
  always taken from the current solution's documents)
@samtrion
samtrion merged commit 1430596 into main Aug 3, 2026
7 checks passed
@samtrion
samtrion deleted the feat/ne0001-fixall branch August 3, 2026 15:18
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.

analyzer: NE0001 Fix-All — sequential provider for batch rename/move

1 participant