100

In a legacy ASP.NET project I have inherited, there are an abundance of methods defined which are used absolutely nowhere.

I'm familiar with the "Find usages" functionality, but would like to be able to generate a list of methods which are not called anywhere in the app. Does such functionality exist?

Micheal Wells
  • 1,149
  • 2
  • 8
  • 8
  • See if this helps: [Resharper- Find all unused classes](http://stackoverflow.com/questions/4646174/resharper-find-all-unused-classes). Or this: [Find unused code](http://stackoverflow.com/questions/245963/find-unused-code). Or this: [Find Unused public functions](http://stackoverflow.com/questions/5846821/find-unused-public-functions). – publicgk Mar 28 '13 at 21:26
  • An interesting problem. Is Resharper able to detect methods that are used as event handlers but only mentioned in the markup? – Ann L. Mar 28 '13 at 21:27
  • Turn on solution wide analysis - unused methods will turn grey – levelnis Mar 28 '13 at 21:31
  • @publicgk Thanks for those! It appears ReSharper used to call them "Unused symbols" and has since renamed them as per Gauthier's answer. – Micheal Wells Mar 28 '13 at 22:34
  • @AnnL. That is a good question! FxCop might be able to do this? – Micheal Wells Mar 28 '13 at 22:35
  • @levelnis This I have been using, what I was asking was if ReSharper could provide me with a list of these, as I have hundreds. – Micheal Wells Mar 28 '13 at 22:36
  • this question is closed because it's a duplicate of another __closed__ question. Wow. – Sylvain Rodrigue Sep 10 '21 at 19:45

1 Answers1

226

You can select ReSharper => Inspect => Codes Issues in solution ; And there, you can group by "Issue Type" and you should see all issues that match with "Type or type member is never used" (unused method goes there)

(And if you click right on it, you can select : "Show only "type or type member is never used" issues" .. and there you go ;)

ReSharper[1]

ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
Gauthier G. Letellier
  • 3,305
  • 1
  • 16
  • 12
  • 5
    Thanks a TON! I'd give you a vote but do not have the reputation. – Micheal Wells Mar 28 '13 at 22:37
  • 2
    To add to this answer, if you don't see any results, go to: ReSharper => Options => Code Inspection => Settings => Check off "Analyze errors in whole solution" – Tarka Mar 03 '14 at 21:14
  • 7
    @Tarka +1 Now seems to be: ReSharper => Options => Code Inspection => Settings => and **check** "_Enable solution-wide analysis_". – Anthony Walsh Jan 11 '16 at 00:49
  • You need to turn on solution-wide analysis mentioned by @AnthonyWalsh to get the non-private to be found - otherwise it shows the "n/a" shown in the screenshot – TKTS Jul 17 '17 at 20:25
  • 1
    "And if you click right on it" - What is "it"? If I do ReSharper => Inspect => Code Issues, it looks NOTHING like the screenshot. I have no checkboxes. There are no context menus or anything that I can see to right-click on. – Clive Galway Feb 14 '18 at 17:10
  • 1
    @CliveGalway I think what was meant by "And if you click right on it" is that you can select the items you wish to filter. The screenshot above is only visible when you click on the '**Filter Issues...**' button in the '**Inspection Results**' panel. Please have a look at [this excellent post](https://chrisseroka.wordpress.com/2013/10/28/find-unused-private-and-public-methods-with-resharper) that includes some helpful screenshots. BTW: Sorry, I would have replied to this sooner if I had seen it! I hope you got sorted. – Anthony Walsh Jan 28 '19 at 00:46
  • 1
    @AnthonyWalsh I honestly don't remember :) Thanks for the clarification and that link though, very handy – Clive Galway Jan 30 '19 at 20:30