How to Add New Refactoring
Discuss the Idea
It is recommended to create issue where you can describe and discuss the idea and if it is accepted by the maintainers you can start with a development.
Add Metadata
Add new refactoring metadata to Refactorings.xml file. It's possible to use template.
See metadata reference for further information.
Generate Code
Run script tools/generate_code.ps1
.
Another option is to launch project CodeGenerator
from Visual Studio.
Implement Refactoring
Go to class RefactoringContext and find a class where new refactoring can be added (or add a new class).
Add Tests
- Add new file to a folder Refactorings.Tests. Convention is to name the file
[Id][Identifier]Tests.cs
.
tip
When writing a test code, tokens [|
and |]
represents start and end of a selected text respectively.
Update Changelog
CHANGELOG.md
### Added
- Add refactoring "REFACTORING_TITLE" ([REFACTORING_ID](https://josefpihrt.github.io/docs/roslynator/refactorings/REFACTORING_ID)) ([#PR_ID](https://github.com/josefpihrt/roslynator/pull/PR_ID))
- Add some description if necessary ...