C#: Unused Method 'method name'

Hello ReSharper Community,


I just have a quick question about how to disable the warning mentioned in this post's subject line, which is, "C#: Unused Method 'method name'.  There are some cases where it makes sense, as in the code snippet below from the Global.asax file:


        void Session_End(object sender,EventArgs e)
        {
            AuthenticationHelper.LogOut();
        }



I'm using version 6.1.37.86 of ReSharper and have been looking in the following location for disabling this warning:


Visual Studio Menu Item ReSharper -> Options -> Code Inspection -> Inspection Severity


I've looked all over this section with no success.  Does this option not exist?  If it exists, is the setting stored elsewhere?


Thank you in advance for your time and help!


Jason

6 comments
Comment actions Permalink

Hello Jason
     The corresponding item for this warning under ReSharper | Options | Code Inspection | Inspection Severity is called 'Type or type member is never used'. You can also turn off this warning using the quick-fix menu (Alt+Enter on the warning in code editor). Please note that you can also use the 'UsedImplicitly' attribute to annotate the methods that are meant to be used implicitly (see http://www.jetbrains.com/resharper/webhelp/Code_Analysis__External_Annotations.html for more information). Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Hello Andrey,

Thanks very much for the quick response and for the great information.  That helped very much!  Unfortunately, it doesn't seem like your solution is applicable to the Global.asax file.  This file type appears to ignore any ReSharper settings you modify.  Is there any way to exclude file extensions/types from ReSharper?

Thanks again and looking forward to hearing back from you soon Andrey!

Jason

0
Comment actions Permalink

Hello Jason
     Sorry for delayed response! I started looking into this problem, but I cannot reproduce the behavior you've described. Could you please attach a small sample solution demonstrating 'Unused method' highlighting in Global.asax file along with a screenshot? Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Hi Andrey,


No problem at all.  Thank you thus far for all the help.  I'm sorry you're unable to recreate this issue.  Per your request, I've attached a screenshot, as well as the physical Global.asax, .cs files.


Thanks and please let me know if you need more information.


Jason



Attachment(s):
Global.asax.cs.zip
Global.asax.zip
GlobalAsaxScreenshot.jpg
0
Comment actions Permalink

Hello Jason
     According to your screenshot those warnings come from some other extension that does code analysis, so it's definitely not ReSharper. In order to make sure, you can disable all third-party extensions except ReSharper and these warnings should not be shown. Thank you!

Andrey Serebryansky

Senior Support Engineer

JetBrains, Inc

http://www.jetbrains.com

"Develop with pleasure!"

0
Comment actions Permalink

Hey Andrey,


Thank you very much for your efforts and that was the culprit!  It was a program we use called PostSharp that was causing this message to reveal itself.


Thank you for all your help Andrey!


Jason

0

Please sign in to leave a comment.