Skip to content

feat: Phase 4b manual-review diagnostics for subclasses and copy-ctor#11

Merged
vbreuss merged 2 commits into
mainfrom
feat/phase-4b
May 15, 2026
Merged

feat: Phase 4b manual-review diagnostics for subclasses and copy-ctor#11
vbreuss merged 2 commits into
mainfrom
feat/phase-4b

Conversation

@vbreuss
Copy link
Copy Markdown
Member

@vbreuss vbreuss commented May 15, 2026

Three additional lossy patterns Testably has no equivalent for. Code-fix provider intentionally registers no rewrite; the analyzer's role here is to make the call sites discoverable.

Patterns added:

  • MockFileSystem.subclass (user-defined class deriving from MockFileSystem)
  • MockFileData.subclass (user-defined class deriving from MockFileData)
  • MockFileData.copyCtor (new MockFileData(MockFileData template))

The two subclass patterns use a NamedType symbol action so each class declaration is flagged once regardless of how many instantiations exist. The base-type walk follows the chain so transitively-derived classes (A : MockFileSystem, B : A) are both flagged. Framework types themselves are skipped.

The copy ctor extends AnalyzeObjectCreation: when constructor.ContainingType is MockFileData and the single parameter is also MockFileData, the call site is flagged. The other MockFileData ctors (text/encoding/byte arrays) keep going through the existing AddFile expansion paths.

The internal Report helper now has overloads for both OperationAnalysisContext and SymbolAnalysisContext, sharing a BuildDiagnostic factory.

Three additional lossy patterns Testably has no equivalent for. Code-fix
provider intentionally registers no rewrite; the analyzer's role here is
to make the call sites discoverable.

Patterns added:
- MockFileSystem.subclass  (user-defined class deriving from MockFileSystem)
- MockFileData.subclass    (user-defined class deriving from MockFileData)
- MockFileData.copyCtor    (new MockFileData(MockFileData template))

The two subclass patterns use a NamedType symbol action so each class
declaration is flagged once regardless of how many instantiations exist.
The base-type walk follows the chain so transitively-derived classes
(A : MockFileSystem, B : A) are both flagged. Framework types themselves
are skipped.

The copy ctor extends AnalyzeObjectCreation: when constructor.ContainingType
is MockFileData and the single parameter is also MockFileData, the call
site is flagged. The other MockFileData ctors (text/encoding/byte arrays)
keep going through the existing AddFile expansion paths.

The internal Report helper now has overloads for both OperationAnalysisContext
and SymbolAnalysisContext, sharing a BuildDiagnostic factory.
@vbreuss vbreuss self-assigned this May 15, 2026
Copilot AI review requested due to automatic review settings May 15, 2026 06:15
@vbreuss vbreuss added the enhancement New feature or request label May 15, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

Test Results

  6 files  ± 0    6 suites  ±0   1m 31s ⏱️ +11s
105 tests +10  105 ✅ +10  0 💤 ±0  0 ❌ ±0 
315 runs  +30  313 ✅ +30  2 💤 ±0  0 ❌ ±0 

Results for commit 10dd4dd. ± Comparison against base commit b1bac25.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Phase 4b “manual review” diagnostics to the System.IO.Abstractions migration analyzer for additional lossy patterns that cannot be safely auto-rewritten, improving discoverability for users during migration.

Changes:

  • Analyzer: flag user-defined subclasses of MockFileSystem / MockFileData at the class declaration (including transitive inheritance).
  • Analyzer: flag new MockFileData(MockFileData template) (copy-ctor) call sites as manual-review.
  • Tests/playground: add analyzer + code-fix “no fix expected” coverage and parity fixtures for these patterns.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
Tests/Testably.Abstractions.Migration.Tests/SystemIOAbstractionsCodeFixProviderTests.MockFileDataTests.cs Adds “no fix” code-fix tests for MockFileData subclass and copy-ctor patterns.
Tests/Testably.Abstractions.Migration.Tests/SystemIOAbstractionsCodeFixProviderTests.ConstructorTests.cs Adds “no fix” code-fix test for MockFileSystem subclass pattern.
Tests/Testably.Abstractions.Migration.Tests/SystemIOAbstractionsAnalyzerTests.cs Adds analyzer tests for subclass + copy-ctor diagnostics, including transitive inheritance.
Tests/Testably.Abstractions.Migration.SystemIOAbstractionsPlayground/ManualReviewTests.cs Adds manual-review parity fixtures demonstrating subclass and copy-ctor behavior.
Source/Testably.Abstractions.Migration.Analyzers/SystemIOAbstractionsAnalyzer.cs Implements symbol-based subclass detection + copy-ctor detection; refactors diagnostic reporting helper.
Source/Testably.Abstractions.Migration.Analyzers/Patterns.cs Introduces new pattern IDs for subclass and copy-ctor manual-review diagnostics.

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

Comment thread Source/Testably.Abstractions.Migration.Analyzers/Patterns.cs
The "Manual-review patterns (Phase 4a)" header in Patterns.cs and the
file-level summary on ManualReviewTests.cs both predate the Phase 4b
patterns (subclasses, copy ctor). Split the Patterns.cs section into
explicit 4a / 4b subsections and rewrite the playground summary to list
both scopes so the docs match the file contents.
@sonarqubecloud
Copy link
Copy Markdown

@vbreuss vbreuss merged commit 9fbd17f into main May 15, 2026
9 checks passed
@vbreuss vbreuss deleted the feat/phase-4b branch May 15, 2026 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants