Analyzing and Optimizing Project References
This feature helps manage your existing project/assembly references, browse usages of the referenced projects/assemblies, and remove unused references. You can invoke this feature on any single project and use the Analyze References Window to analyze and optimize project references.
In this topic:
Analyzing project references
The Analyze References tool window displays project/assembly references in the current project, and let you explore how exactly the references are used. To explore usages of a specific assembly, namespace or type, you can filter them by kind and group them.
The symbol icons could help you distinguish between different kinds of symbols. Each usage is displayed with the line number and column; different icons mean different kinds of usages like read, write, attribute, or invocation usage. You can double-click any usage to navigate directly to the source code.
To analyze project references
- In the Solution Explorer, select a project that you want to analyze or its References node.
Do one of the following:
- Right-click the selection and choose Optimize References in the context menu.
- Press N/A.
- Use controls in the Analyze References Window to explore project references.
Removing unused references
The easiest way to clean up project references is to click Remove All Unused References on the toolbar. If you want ro retain some unused references or remove some of the used references (and manually resolve the compilation errors that follow), you can make the corresponding selection and click Remove Selected References .
When you remove project and assembly references, ReSharper also deletes all redundant namespace import directives that reference namespaces from the removed assemblies.
All Visual Studio projects must reference
and, starting from Visual Studio 2010,
assemblies. These assemblies are marked with the pin
icon and you cannot remove these references.
References that are needed for compilation, independently of whether they are used or not, are displayed in the References required by the compiler group. References in this group are normally have 'related usages', that is, implicit (non-direct) usages. In the simplest case, related usages are caused by a type’s hierarchy. That is, if you use a certain type, you have to reference all assemblies containing that type’s supertypes.
There are two more ways of cleaning project and assembly references.
- You can invoke the Remove Unused References command on the project or on the References node in the Solution Explorer.
- You can expand the References node in the Solution Explorer, select the references you want to remove and invoke the Safe Delete refactoring, which either silently removes unused references or opens a dialog showing how and where the selected references are used.