ReSharper Help

Refactorings

ReSharper provides an extensive set of automated solution-wide code refactorings that allow you to rename, move, and safely delete symbols; introduce and inline fields, variables, or parameters, and carry out many more transformations painlessly.

Refactorings are available for most of the supported languages and project items. To learn more about specific refactorings, study the following sections:

To perform a refactoring

  1. Set your caret at a symbol, select a code fragment that you want to refactor, or select an item in a tool window.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor, and then select a desired refactoring.
    • In the editor, File Structure window, or other ReSharper window, right-click the item you want to transform, choose Refactor from the context menu, and then select the required refactoring.  
    • On the main menu, choose  ReSharper | Refactor | Refactor This, or press Ctrl+Shift+R to display the list of applicable refactorings, and select one of them. You can also choose Refactor This in the context menu of a selection.
    • If a refactoring could fix a code issue that ReSharper detects and highlights in the editor, the corresponding action indicator Coding_Assistance__Context_Actions__icon_refactor appears to the left of the code issue. You can click on this indicator or press Alt+Enter to check the suggested refactoring and apply if if necessary.
    • Use default keyboard shortcuts assigned to specific refactorings, or assign custom shortcuts to your favorite refactorings.
  3. If the selected refactoring requires user input, the refactoring wizard opens. Note that the wizard's dialog boxes are not modal, so you can edit the code while the wizard is open.
    To roll back refactoring actions, the wizard provides the option  To enable Undo, open all files with changes for editing. If you select this option, ReSharper opens all modified files in new editor tabs and enables you to roll the refactoring back. In this case, you will need to save the changes yourself. If this option is not selected, ReSharper saves modified files automatically, without opening them.
  4. If a refactoring operation would cause code conflicts (such as duplicate names, visibility conflicts, etc.), the wizard displays the list of conflicts on the last step, before you apply the refactoring. For some conflicts, the wizard can also suggest quick-fixes. For more information, see Resolving Conflicts in Refactorings.

Some refactorings are available immediately after you modify code in the editor. For more information, see Inplace Refactorings

Most of ReSharper's refactorings are available in C# and Visual Basic .NET , some are available in several languages, others are language-specific. The table below lists all refactorings and languages/technologies where they are supported.

The instructions and examples given in the topics within this section address the use of refactorings in C#. For more information on refactorings available for specific languages, see the corresponding topics in the ReSharper by Language section.

Refactoring C# VB.NET C++ HTML ASPX Razor JavaScript TypeScript CSS XML XAML RESX Build Scripts
Refactor This feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available
Change Signature feature_available feature_available feature_available
Convert Abstract Class to Interface feature_available feature_available
Convert Anonymous to Named Type feature_available
Convert Extension Method to Plain Static feature_available feature_available
Convert Indexer to Method feature_available feature_available
Convert Interface to Abstract Class feature_available feature_available
Convert Method to Indexer feature_available feature_available
Convert Method to Property feature_available feature_available
Convert Property to Auto-Property feature_available feature_available
Convert property to method(s) feature_available feature_available
Convert Static to Extension Method feature_available feature_available
Copy Type feature_available feature_available feature_available feature_available
Encapsulate Field feature_available feature_available
Extract Class feature_available feature_available feature_available
Extract Class from Parameters feature_available feature_available
Extract Interface feature_available feature_available feature_available
Extract Method feature_available feature_available feature_available
Extract Superclass feature_available feature_available feature_available
Extract CSS Style feature_available feature_available feature_available feature_available
Extract XAML Resource feature_available
Extract XAML Style feature_available
Inline Class feature_available feature_available feature_available feature_available
Inline Field feature_available feature_available feature_available
Inline Method feature_available feature_available
Inline Parameter feature_available feature_available
Inline Resource feature_available feature_available feature_available feature_available
Inline XAML Resource feature_available
Inline Variable feature_available feature_available feature_available
Introduce field feature_available feature_available feature_available
Introduce Namespace Alias feature_available
Introduce parameter feature_available feature_available
Introduce variable feature_available feature_available feature_available feature_available
Introduce Variable for Substring feature_available feature_available feature_available feature_available
Make Method Non-Static feature_available feature_available feature_available
Make Method/Property Static feature_available feature_available feature_available
Make Shared feature_available
Move Instance Method feature_available feature_available
Move Resource feature_available feature_available feature_available feature_available
Move to Resource feature_available feature_available feature_available feature_available feature_available feature_available
Move to Another File feature_available feature_available feature_available feature_available feature_available
Move to Another Folder feature_available feature_available feature_available
Move to Another Type feature_available feature_available
Move type to another namespace/module feature_available feature_available feature_available feature_available
Move Type to Outer Scope feature_available feature_available
Pull Members Up feature_available feature_available
Push Members Down feature_available feature_available feature_available
Rename feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available feature_available
Replace Constructor with Factory Method feature_available feature_available
Safe Delete feature_available feature_available feature_available feature_available feature_available
Transform Out Parameters feature_available feature_available
Use Base Type Where Possible feature_available feature_available feature_available feature_available

See Also

Last modified: 27 August 2015