Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way I can have Resharper ignore an unused reference?

Using Resharper, we can right click on References for a project and select Optimize References. This shows us class libraries that are not in use or required by the compiler.

I have a class library that is only to be used as a reference (won't ever be a need to actually use the code). The dll is setup to inject itself upon start up as long as it is part of the references. In case you are curious why this would ever be done, it handles not found and errors for ASP.NET MVC projects (Nuget package page).

Is there any possible way that I can tell Resharper that this reference is either part of the required by the compiler or a part of the used references? I just want to try and prevent developers from removing my dll on accident.

like image 703
techvice Avatar asked Nov 10 '22 22:11

techvice


1 Answers

You can interface Resharper with StyleCop. It allow warning in your code based on StyleCop settings. For each warning there is a way (using the "Resharper bubble") to disable a warning : http://tof.canardpc.com/view/49d10973-eb25-4a26-90b2-19d872083285.jpg

it's add a comment line in your code to disable alert on the warning ;

// ReSharper disable once RedundantUsingDirective
using My.Unused.Reference;

After some tests, saldy it seems Resharper doesn't care about that when you trigger the "Optimize Reference"

like image 78
Jalkar Avatar answered Nov 14 '22 23:11

Jalkar