ReSharper
 
Get ReSharper
Get your hands on the new features ahead of the release by joining the Early Access Program for ReSharper 2025.1! Learn more

Safe Delete refactoring

Last modified: 08 October 2024

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 more information about other languages, refer to corresponding topics in the Languages and frameworks section.