Skip to content

Add helper composition analyzers and safe inheritance fix#157

Merged
cwinland merged 9 commits into
masterfrom
feature/fmoq0037-0038-helper-composition
May 2, 2026
Merged

Add helper composition analyzers and safe inheritance fix#157
cwinland merged 9 commits into
masterfrom
feature/fmoq0037-0038-helper-composition

Conversation

@cwinland
Copy link
Copy Markdown
Owner

@cwinland cwinland commented May 2, 2026

Summary

Add the helper-composition migration work for MockerTestBase<T> wrappers and thin helper indirection.

This PR:

  • adds FMOQ0037 and FMOQ0038 ids, descriptors, and migration catalog entries
  • adds one shared helper-composition classifier used by analyzer and code-fix paths
  • adds the FMOQ0037 analyzer plus a narrow direct-inheritance code fix
  • adds the FMOQ0038 advisory analyzer plus explicit regressions for FMOQ0026, FMOQ0030, FMOQ0031, and FMOQ0032
  • preserves existing implemented interfaces during the FMOQ0037 direct-inheritance rewrite

Validation

  • dotnet test c:\Users\chriswin\source\repos\FastMoq\FastMoq.Analyzers.Tests\FastMoq.Analyzers.Tests.csproj
  • Full analyzer suite passed: 813 tests, 0 failures

Issues

Closes #153
Closes #154
Closes #155
Closes #156

@cwinland cwinland requested a review from Copilot May 2, 2026 16:48
@cwinland cwinland self-assigned this May 2, 2026
Copy link
Copy Markdown
Contributor

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 migration analyzers and a narrow code fix to steer tests away from thin MockerTestBase<T> helper-instance composition and toward direct inheritance (or shared inherited bases), aligning analyzer guidance with the v4 migration direction.

Changes:

  • Add new diagnostics FMOQ0037 (warning + code fix) and FMOQ0038 (advisory analyzer only), including descriptors and migration catalog entries.
  • Introduce shared helper-composition classification in FastMoqAnalysisHelpers used by analyzer/code-fix paths.
  • Add analyzer + regression tests, including code-fix rewrite coverage and non-fixable blocking scenarios.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
docs/migration/README.md Adds FMOQ0037/FMOQ0038 to the analyzer catalog.
FastMoq.Analyzers/FastMoqAnalysisHelpers.cs Adds helper-composition candidate classification and fix-block reasoning helpers.
FastMoq.Analyzers/DiagnosticIds.cs Adds new diagnostic IDs for FMOQ0037/FMOQ0038.
FastMoq.Analyzers/DiagnosticDescriptors.cs Adds new descriptors/messages for the new diagnostics.
FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs Registers and implements the FMOQ0037 direct-inheritance rewrite code fix.
FastMoq.Analyzers/Analyzers/DirectMockerTestBaseInheritanceAnalyzer.cs Adds the FMOQ0037 analyzer.
FastMoq.Analyzers/Analyzers/UnnecessaryMockerTestBaseHelperIndirectionAnalyzer.cs Adds the FMOQ0038 advisory analyzer.
FastMoq.Analyzers.Tests/MigrationAnalyzerTests.cs Adds tests for candidates, diagnostics, code-fix rewrites, and regressions.
FastMoq.Analyzers.Tests/AnalyzerTestHelpers.cs Exposes a helper to build Documents for new tests.

Comment thread FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs Outdated
Comment thread FastMoq.Analyzers/Analyzers/UnnecessaryMockerTestBaseHelperIndirectionAnalyzer.cs Outdated
Comment thread FastMoq.Analyzers.Tests/MigrationAnalyzerTests.cs Outdated
Comment thread FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs
Comment thread FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs Outdated
Copy link
Copy Markdown
Contributor

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

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

Comment thread FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs
Comment thread FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs
Copilot AI review requested due to automatic review settings May 2, 2026 17:42
Copy link
Copy Markdown
Contributor

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

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

Comment thread FastMoq.Analyzers/CodeFixes/FastMoqMigrationCodeFixProvider.cs
@cwinland cwinland enabled auto-merge (squash) May 2, 2026 18:09
@cwinland cwinland disabled auto-merge May 2, 2026 18:09
@cwinland cwinland merged commit ab9a304 into master May 2, 2026
7 checks passed
@cwinland cwinland deleted the feature/fmoq0037-0038-helper-composition branch May 2, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants