coderushforroslyn-115806-refactoring-assistance.md
Refactorings are small changes to working code that improve the internal structure without altering the external behavior of that code.
The Refactorings section describes each refactoring in detail. The description includes the purpose of the refactoring, its availability, and the “how to use” example.
Invoke the Code Actions Menu. Place the caret in the part of the code you want to change, for example, on a boolean method parameter, and press Ctrl + . or Ctrl + ~.
Choose the action from the invoked menu. For example, Boolean to Enum.
Press Enter to generate code in the selected position.
class TestClass {
private int TestMethod(TestMethodParam a) {
if (a == TestMethodParam.Success)
return 1000;
else
return 1024;
}
}
public enum TestMethodParam {
Success,
Failure
}
CodeRush includes over 60 refactorings you can use to improve C#, Visual Basic, XAML, and Blazor code.
You can define a set of programming style rules that CodeRush applies to your code when you refactor. Refer to the Programing Style Rules topic for more information.
You can apply refactorings from code sections in .razor files.
Note
The refactorings for Blazor are unable to update references in closed .razor files. Make sure all files that may be impacted by a particular refactoring are open in Visual Studio before applying it.
See Also