Refactor String/Collection Assert code-fix scaffolding into shared base#8848
Conversation
Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors duplicated Roslyn code-fix scaffolding from the MSTest analyzer code fixers into a shared base class, keeping the StringAssert/CollectionAssert-specific rewrite logic in their respective fixers.
Changes:
- Introduces
AssertToAssertFixerBaseto centralize commonCodeFixProviderplumbing (FixAll provider, diagnostic property extraction, invocation guards, and CodeAction registration). - Updates
StringAssertToAssertFixerto derive from the new base and delegate into its existing StringAssert rewrite. - Updates
CollectionAssertToAssertFixerto derive from the new base, including optionalFixKindhandling, and delegate into its existing CollectionAssert rewrite.
Show a summary per file
| File | Description |
|---|---|
| src/Analyzers/MSTest.Analyzers.CodeFixes/StringAssertToAssertFixer.cs | Migrates to the shared base and keeps only StringAssert-specific rewrite behavior. |
| src/Analyzers/MSTest.Analyzers.CodeFixes/CollectionAssertToAssertFixer.cs | Migrates to the shared base and retains fix-kind routing + CollectionAssert-specific rewrites. |
| src/Analyzers/MSTest.Analyzers.CodeFixes/AssertToAssertFixerBase.cs | Adds a shared code-fix pipeline used by both fixers. |
Copilot's findings
- Files reviewed: 3/3 changed files
- Comments generated: 1
Replace the new public abstract AssertToAssertFixerBase with an internal static AssertToAssertFixerHelpers class. The concrete code fix providers now inherit CodeFixProvider directly and call into the helper, avoiding adding new public API surface area. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@copilot resolve the merge conflicts in this pull request |
… to AssertToAssertAnalyzerHelpers Co-authored-by: Evangelink <11340282+Evangelink@users.noreply.github.com>
Resolved. The two conflicts were in |
StringAssertToAssertFixerandCollectionAssertToAssertFixerhad duplicated code-fix scaffolding (GetFixAllProvider, diagnostic-property extraction, invocation-node guards, and root replacement flow). This change consolidates that shared pipeline while preserving each fixer’s rule-specific rewrite behavior.Shared code-fix pipeline
AssertToAssertFixerBasewith:GetFixAllProvider(BatchFixer)RegisterCodeFixesAsyncscaffoldFixKindproperty handlingString assert fixer migration
StringAssertToAssertFixernow derives fromAssertToAssertFixerBaseCollection assert fixer migration
CollectionAssertToAssertFixernow derives fromAssertToAssertFixerBaseFixKindrouting and rewrite logic