I was wondering what the various costs of referencing assemblies in a .NET solution are. I'm interested in both technical and organizational costs.
Some examples:
By removing any unused references in your application, you are preventing the CLR from loading the unused referenced modules at runtime. Which means that you will reduce the startup time of your application, because it takes time to load each module and avoids having the compiler load metadata that will never be used.
Navigate to Tools > Options > Text Editor > Code Cleanup. Add a check in the "Run Code Cleanup profile on Save." Be sure to select the appropriate profile you want to execute automatically whenever you save!
Instead of opening the Nuget Packagemanager and uninstalling things manually there is faster way: right click on the project in the Solution Explorer and go into R# Refactor menu. There you'll find the Remove unused references menu item.
If you reference an assembly in a project but actually don't use any types in that assembly the unused assembly will not be part of your final product. The reference is removed at compile time.
The only "overhead" of referencing unused assemblies is during development where referencing many unused assemblies may confuse the developer about what dependencies the project has. Each new assembly in your project will also create some overhead for IntelliSense and the compiler but in most cases you wont notice.
ReSharper has a function to analyze if a referenced assembly is unused.
In my opinion the organizational overhead for me (and my co-workers) to even think about unused references (why do we need XML here?) is enough motivation to remove them. Consequently, I have never considered the impact on deployment or performance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With