Does resharper have problems with asp.net mvc?

I am using the latest version of resharper. Just downloaded and installed last week, so I'm new to using it. The problem is that in my ASP.NET MVC application, all my controllers say that they are never used, and all the methods in the controller say that they are never used.

Is there a way to suppress messages or rephrase to understand that they are being used?

+4
source share
3 answers

You can turn on / off the various warnings and tips that Resharper gives you.

HOWEVER, if you write unit tests, then they will be used, and Resharper will be happy.

Update

You might think that Resharper ignores the unused members of your controller by doing this at the top and bottom of your controller class ...

public class MyController: Controller { // ReSharper disable UnusedMember.Global ... // ReSharper restore UnusedMember.Global } 

... or at least put these comments around public methods on your controller (I use StyleCop, and so all public methods will be grouped anyway. It's pretty unobtrusive and will get rid of this warning from Resharper.

+9
source

Yep, the current version of ReSharper does not put links to MVC controllers (although the next one will be).

In the meantime, you can mark the controller class and action methods with the ImplicitUse attribute. You can find it in the JetBrains.Annotations assembly. If you do not want an external dependency, you can add the necessary annotation attributes to your project, you will find them in ReSharper-> Options-> Code Inspection-> Code Annotation-> Copy default implementation.

+6
source

No, I know that this will make Resharper β€œknow” that the method is being used (I have never experienced this problem with Resharper).

If you do not want the various scan options to be turned on / off globally, you can disable special inspection messages with comments. So ...

 // ReSharper disable UnusedPrivateMember private void NotUsed () { // ... Code ... } // ReSharper restore UnusedPrivateMember 
+1
source

All Articles