Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resharper Method is never used

I have a public facing interface in one project that will end up becoming a nuget package. Here is the code:

public interface MyInterface
{
    void MyMethod();
}

Now every method in this interface is not used in this library but is used in other via the package. However, every single method here has a warning of Method x is never used.

Is there a simple way to tell ReSharper to ignore every public method in every project in every solution that I ever open to not perform this check in public methods.

I have a couple of ways to fix this but it is far too tedious.

Option 1: [UsedImplicitly] on every method inside my class. This is far too tedious in my opinion. Option 2: [SuppressMessage("ReSharper", "UnusedMember.Global")] A little less tedious, but still have to implement on every class.

There has to be a better way?

I also read somewhere that this only happens if Enable solution-wide analysis is checked. In my case it is not. I found this setting under Reshaper Options > Code Inspection > Settings

like image 937
Bagzli Avatar asked Jul 15 '18 22:07

Bagzli


1 Answers

In your case, since you've mentioned that SWEA is disabled, I would recommend disabling the following checkbox ReSharper | Options | Code Inspection | Settings | General | Show unused non-private type members when solution-wide analysis is off.

like image 112
Alexander Kurakin Avatar answered Sep 30 '22 11:09

Alexander Kurakin