Skip to content

feat: Phase 1 analyzer + code fix for parameterless MockFileSystem ctor#6

Merged
vbreuss merged 2 commits into
mainfrom
feat/phase-1-migration-skeleton
May 14, 2026
Merged

feat: Phase 1 analyzer + code fix for parameterless MockFileSystem ctor#6
vbreuss merged 2 commits into
mainfrom
feat/phase-1-migration-skeleton

Conversation

@vbreuss

@vbreuss vbreuss commented May 14, 2026

Copy link
Copy Markdown
Member

Detect new System.IO.Abstractions.TestingHelpers.MockFileSystem() (parameterless) and rewrite the file's using directive to Testably.Abstractions.Testing, proving the analyzer → diagnostic → code fix → tests wiring end-to-end. The diagnostic carries a pattern property so later phases can layer in more rewrites under the same TestablyAbstractionsMigration001 id.

  • Add TestableIoSymbols resolver in Analyzers/Common that bails when the TestingHelpers assembly is not referenced.
  • Replace the existing TestingHelpers using in place to preserve trivia / line endings; only append a new using when there is no existing one to repurpose.
  • Drop the global using System.IO.Abstractions.TestingHelpers; from the playground / Example.Tests so per-file usings remain rewritable.
  • Add a sentinel test that round-trips a rooted Unix-style path on Windows through both libraries via the parameterless constructor.

Detect `new System.IO.Abstractions.TestingHelpers.MockFileSystem()` (parameterless)
and rewrite the file's using directive to `Testably.Abstractions.Testing`, proving
the analyzer → diagnostic → code fix → tests wiring end-to-end. The diagnostic
carries a `pattern` property so later phases can layer in more rewrites under the
same `TestablyAbstractionsMigration001` id.

- Add `TestableIoSymbols` resolver in `Analyzers/Common` that bails when the
  TestingHelpers assembly is not referenced.
- Replace the existing TestingHelpers using in place to preserve trivia / line
  endings; only append a new using when there is no existing one to repurpose.
- Drop the global `using System.IO.Abstractions.TestingHelpers;` from the
  playground / Example.Tests so per-file usings remain rewritable.
- Add a risk-#1 sentinel test that round-trips a rooted Unix-style path on
  Windows through both libraries via the parameterless constructor.
@vbreuss vbreuss self-assigned this May 14, 2026
Copilot AI review requested due to automatic review settings May 14, 2026 15:36
@vbreuss vbreuss enabled auto-merge (squash) May 14, 2026 15:37
@vbreuss vbreuss disabled auto-merge May 14, 2026 15:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Wires up the first end-to-end slice of the migration tool: an analyzer that flags the parameterless new System.IO.Abstractions.TestingHelpers.MockFileSystem() and a code fix that rewrites the file's using directives to Testably.Abstractions.Testing. The diagnostic carries a pattern property so future phases can layer additional rewrites under the same diagnostic id.

Changes:

  • Add TestableIoSymbols resolver + Patterns discriminator and register an ObjectCreation operation action in SystemIOAbstractionsAnalyzer that reports only the zero-argument MockFileSystem ctor.
  • Implement SystemIOAbstractionsCodeFixProvider.RewriteUsingsAsync, which replaces the TestingHelpers using in place (preserving trivia), removes it when a Testably using already exists, or appends a new one.
  • Drop the global using System.IO.Abstractions.TestingHelpers; from the playground and Example.Tests, add risk-#1 sentinel tests for Unix-style path round-tripping, and flesh out the analyzer / code-fix unit tests.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
Source/Testably.Abstractions.Migration.Analyzers/SystemIOAbstractionsAnalyzer.cs Registers compilation-start + operation actions to flag parameterless MockFileSystem ctor with a pattern property.
Source/Testably.Abstractions.Migration.Analyzers/Patterns.cs New constants for the diagnostic pattern property key and Phase 1 value.
Source/Testably.Abstractions.Migration.Analyzers/Common/TestableIoSymbols.cs New helper caching TestingHelpers type symbols; returns null when the assembly is not referenced.
Source/Testably.Abstractions.Migration.Analyzers.CodeFixers/SystemIOAbstractionsCodeFixProvider.cs Implements pattern-dispatched code action that rewrites the file's TestingHelpers using to Testably.Abstractions.Testing.
Tests/Testably.Abstractions.Migration.Tests/SystemIOAbstractionsAnalyzerTests.cs Adds analyzer tests for flagged/not-flagged ctor cases and no-op when assembly is missing.
Tests/Testably.Abstractions.Migration.Tests/SystemIOAbstractionsCodeFixProviderTests.cs Adds code-fix tests for explicit and target-typed new MockFileSystem().
Tests/Testably.Abstractions.Migration.SystemIOAbstractionsPlayground/Usings.cs Removes the global TestingHelpers using so per-file usings can be rewritten.
Tests/Testably.Abstractions.Migration.SystemIOAbstractionsPlayground/UnixPathSmokeTest.cs New smoke test exercising rooted Unix-style paths through the parameterless ctor.
Tests/Testably.Abstractions.Migration.SystemIOAbstractionsPlayground/MockFileSystemSamples.cs Adds a real Phase 1 call site for the analyzer/code fix to target.
Tests/Testably.Abstractions.Migration.Example.Tests/Usings.cs Drops the global TestingHelpers using so per-file aliasing works.
Tests/Testably.Abstractions.Migration.Example.Tests/SystemIOAbstractionsMigrationExamples.cs Adds risk-#1 sentinel theory comparing both libraries and a post-migration IFileSystem check.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Source/Testably.Abstractions.Migration.Analyzers/Common/TestableIoSymbols.cs Outdated
@github-actions

github-actions Bot commented May 14, 2026

Copy link
Copy Markdown

Test Results

 6 files  ± 0   6 suites  ±0   32s ⏱️ +32s
 5 tests + 5   5 ✅ + 5  0 💤 ±0  0 ❌ ±0 
15 runs  +15  15 ✅ +15  0 💤 ±0  0 ❌ ±0 

Results for commit e228ce7. ± Comparison against base commit a40cb31.

♻️ This comment has been updated with latest results.

@sonarqubecloud

Copy link
Copy Markdown

@vbreuss vbreuss merged commit ca49479 into main May 14, 2026
9 checks passed
@vbreuss vbreuss deleted the feat/phase-1-migration-skeleton branch May 14, 2026 15:49
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.

2 participants