Safe Delete refactoring
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, JetBrains Rider 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.
In this topic:
To safely delete a symbol
- Select a symbol in one of the following ways:
- In the editor, set the caret at the name of a symbol.
- Select a symbol in the Structure window.
- Do one of the following: Safe Delete dialog will open.
- If the symbol has base symbols or inheritors or both, JetBrains Rider prompts you to specify which symbols should be removed.
In case of a type, you can delete the type and all its inheritors.
In case of a polymorphic method or property, you can delete the base members as well by choosing one of the following options:
- To apply the refactoring, click Next.
- If no usages are found, the symbol is deleted immediately. Otherwise, the detected conflicts are shown in the next steep of the refactoring wizard and you will need to resolve the conflicts manually.
To safely delete project/assembly references
- In the Solution Explorer, select one or more references you want to delete.
- Do one of the following:
- If only unused references are selected, the refactoring is performed immediately. Otherwise, the Safe Delete Assembly Reference dialog appears with all usages of symbols from the projects/assemblies being deleted. You can click on each usage to navigate to the source code and see if you can delete it. The list of usages in the dialog is updated automatically as you change the code.
- As soon as there are no more usages in the dialog, you can click Next to complete the deletion.
- If you want to delete the selected assembly references and get rid of the usages later, clear the Remove only unused references and click Next.