跳到正文
FunCoding

add-refactoring

官方

Use when adding a new RR#### refactoring in roslynator, editing Refactorings.xml, registering in RefactoringContext, or when refactorings-testing.md shows XunitRefactoringVerifier — in-repo uses AbstractCSharpRefactoringVerifier and CHANGELOG.md.

Star
3,506
最近提交
2026年11月1日

.claude/skills/add-refactoring/SKILL.md

在 GitHub 上查看

Add Refactoring

Overview

Refactorings are metadata-driven: Refactorings.xml → codegen → register in RefactoringContext → implement → test → changelog.

When to Use

  • New RR#### refactoring in an approved issue
  • Registering a refactoring action on a syntax kind
  • <OptionKey> required on every refactoring entry

Not for: analyzers (add-analyzer), compiler fixes (add-compiler-diagnostic-fix), deprecation (deprecate-analyzer-or-refactoring).

Gate: approved GitHub issue (CONTRIBUTING.md).

Read references/implementation.md before writing tests — public refactorings-testing.md uses XunitRefactoringVerifier, which does not match in-repo tests.

Confirm metadata parameters (hard gate)

STOP. Do NOT edit Refactorings.xml, run codegen, or implement until the user has confirmed every required parameter below. Do not invent values the user (or issue) did not state.

Use AskQuestion when available; otherwise ask conversationally. Batch related choices.

ParameterRequired?Notes
IdproposeCompute next free RR#### from Refactorings.xml; do not ask unless the issue conflicts or multiple ids are plausible
IdentifieryesPascalCase; drives generated names
TitleyesShort description (light-bulb text)
OptionKeyyesEditorConfig key segment → roslynator_refactoring.<key>.enabled
Syntaxes / Spanyes for docsWhere it can be invoked (documentation only; registration is in code)
Summary / samplesrecommendedConfirm if not in the issue

When proposing Id, state the chosen value in your plan/summary (e.g. “using next free RR0218”). Skip asking other parameters only when the approved issue or the user's message already states the value explicitly.

Quick Reference

StepLocation / command
Metadatasrc/Refactorings.xml
Codegencd tools && pwsh ./generate_code.ps1
RegisterRefactoringContext.cs or helper under Refactorings/CSharp/Refactorings/
Implementsame folder
Testssrc/Tests/Refactorings.Tests/RR####IdentifierTests.cs
ChangelogCHANGELOG.md under ## [Unreleased]

Implementation

  1. Confirm metadata parameters (hard gate above).
  2. Details and examples: references/implementation.md.

Changelog:

- Add refactoring "TITLE" ([RR####](https://josefpihrt.github.io/docs/roslynator/refactorings/RR####)) ([#PR](https://github.com/dotnet/roslynator/pull/PR))

Verify:

cd tools && pwsh ./generate_code.ps1
cd src && dotnet build Roslynator.sln
cd src && dotnet test Tests/Refactorings.Tests --no-build --filter "FullyQualifiedName~RR####"
cd src && dotnet format Roslynator.sln --no-restore --verify-no-changes --severity info

Common Mistakes

MistakeFix
Guess Title / OptionKey / IdentifierAsk — hard gate above
Follow refactorings-testing.md verbatimIn-repo: AbstractCSharpRefactoringVerifier + RefactoringId override
Missing <OptionKey>Required — EditorConfig id for enable/disable
Codegen from repo rootcd tools && pwsh ./generate_code.ps1
`[...
Only <Syntaxes> / <Span>Documentation-only; registration is in code

相似的 Skill

rea-analysis-optimization

MOmorluto/rea485k近 7 天新增 9,215 个 star

codebase-design

MAmattpocock/skills336k近 7 天新增 5,004 个 star

精选

diagnosing-bugs

诊断困难 bug 和性能回归,用测试或脚本构建反馈循环定位问题。

MAmattpocock/skills336k近 7 天新增 5,004 个 star

setup-ts-deep-modules

MAmattpocock/skills336k近 7 天新增 5,004 个 star

code-review

MAmattpocock/skills336k近 7 天新增 5,004 个 star

implement

MAmattpocock/skills336k近 7 天新增 5,004 个 star