ReSharper traditionally provides an extended set of automated code refactorings that allow you to rename, move, and safely delete symbols; introduce and inline fields, variables, or parameters, and carry out many more improvements.
NoteVisual Studio provides its own Refactor menu that is available from both main and context menus. By default, ReSharper hides the native Visual Studio menu. To make it accessible, choose ReSharper | Options, open the Environment | General tab, and select Hide overridden Visual Studio menu items.
- Select an object or a code fragment that you want to refactor.
- To select a refactoring, do one of the following:
- On the main menu, choose ReSharper | Refactor, and select a refactoring from the submenu.
- In the File Structure window, right-click the desired node, choose Refactor from the context menu, and select the required refactoring from the submenu.
- 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 execute this action through the context menu of a selection.
- Click the refactor icon to the left of a code line to display the list of context actions that act as shortcuts to contextually applicable refactorings.
keyboard shortcutsassigned to refactorings.
- 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 the 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.
- If a refactoring operation causes code conflicts (such as duplicate names, visibility conflicts,
etc.), the wizard displays
the list of conflicts on the last step. For some conflicts, the wizard can also suggest quick-fixes.
For more information,
Resolving Conflicts in Refactorings.