Add helper composition analyzers and safe inheritance fix#157
Merged
Conversation
Contributor
There was a problem hiding this comment.
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) andFMOQ0038(advisory analyzer only), including descriptors and migration catalog entries. - Introduce shared helper-composition classification in
FastMoqAnalysisHelpersused 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add the helper-composition migration work for
MockerTestBase<T>wrappers and thin helper indirection.This PR:
FMOQ0037andFMOQ0038ids, descriptors, and migration catalog entriesFMOQ0037analyzer plus a narrow direct-inheritance code fixFMOQ0038advisory analyzer plus explicit regressions forFMOQ0026,FMOQ0030,FMOQ0031, andFMOQ0032FMOQ0037direct-inheritance rewriteValidation
dotnet test c:\Users\chriswin\source\repos\FastMoq\FastMoq.Analyzers.Tests\FastMoq.Analyzers.Tests.csproj813tests,0failuresIssues
Closes #153
Closes #154
Closes #155
Closes #156