ReSharper Web Help

From time to time you refactor your code and need to remove obsolete or unused symbols. To be sure that symbols are removed properly, use the Safe Delete refactoring.

To delete a symbol safely
  1. Place the caret at the name of a symbol that you want to delete.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Safe Delete.
    • Choose Refactor | Safe Delete on the context menu.
    • Press Ctrl+Shift+R, then click Safe Delete.
    • Press Alt+Delete.
  3. The Safe Delete dialog box opens. If the symbol has base symbols or inheritors or both, ReSharper prompts you to specify what symbols should be removed and what usages should be searched for. So, depending on the symbol and its hierarchy, you can try to:
    • remove the whole hierarchy of the symbol: the current symbol, all bases symbols and all its inheritors
    • remove the current symbol and all its inheritors
    • remove the current symbol only


    If there is no hierarchy, confirm the remove action by clicking Next.
  4. If no usages are found, the symbol is deleted immediately. If ReSharper finds usages, it shows the Conflicts page. Look through the list and try to resolve conflicts.

     Note

    Usages that can be safely deleted are marked with the icon. Removing usages marked with the icon leads to compilation errors.
    Click Next to delete the symbol.

Using the Safe Delete refactoring you can safely remove not only symbols, but also assembly references.

To safely remove assembly references
  1. Select assembly references you want to remove in the Solution Explorer window.
  2. Do one of the following:
    • On the main menu, choose ReSharper | Refactor | Safe Delete.
    • Press Ctrl+Shift+R, then click Safe Delete Assembly Reference.
    • Press Alt+Delete.
  3. If only unused references are selected, then the refactoring is performed immediately without displaying the dialog. Otherwise, the Safe Delete Assembly Reference dialog box is displayed.
  4. Click Next to apply the refactoring.

 Note

When you perform an undo action, pay attention that all changes in source code will be reverted, but assembly references will not be added back.

See Also

Procedures