Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Visual Studio's Remove Unused References Safe?

I just recently went through one of our solutions, and removed unused references from every project. There is some concern that this could cause issues (perhaps needing references of references, or not playing nicely with Nuget). Does someone know if this operation is safe? Is it possible that it could remove something that is actually needed?

enter image description here

like image 787
Bob Horn Avatar asked Aug 13 '18 14:08

Bob Horn


1 Answers

It is safe if you do not load assemblies dynamicly from code (eg., dependency injection with configuration saved in file, xml, json..., use Assembly.Load, ...). In other case needed assemblies could not be copied to destination folder when debug/publish application and you will get runtime errors if you do not copy them by yourself.

In most cases you do not do that in your solution and it is perfectly safe.

like image 83
Mabakay Avatar answered Sep 27 '22 19:09

Mabakay