ReSharper
 
Get ReSharper
You are viewing the documentation for an earlier version of ReSharper.

Safe Delete refactoring

Last modified: 21 July 2022

ReSharper | Refactor | Safe Delete…

Ctrl+R D (ReSharper_SafeDelete)

If you are going to delete any other symbol or a project/assembly reference use this refactoring to ensure that the solution will compile after the deletion. If there are no references to the deleted item, or if all references are safely collapsible, the item will be deleted right away. Otherwise, ReSharper will show you all the references that are not safe to delete, allowing you to edit the corresponding code. If there are any empty files left after removing the symbol, the refactoring can also remove these files.

There are other ways of cleaning project and assembly references.

  • You can invoke the Optimize References command, which will let you analyze all references and remove unused ones.

  • You can invoke the Remove Unused References command on the project or on the References node in the Solution Explorer.

This feature is supported in the following languages and technologies:

The instructions and examples given here address the use of the feature in C#. For details specific to other languages, see corresponding topics in the ReSharper by language section.