25

I have a solution.
I have an interface.
I have several classes that implement the interface.

I can use "Find All References" in order to find where the interface is implemented, but it also returns results where the interface is the return type, or where a class explicitly implements an interface's method.

Is there a better way to quickly/easily find which classes implement the interface?

River
  • 8,585
  • 14
  • 54
  • 67
John B
  • 20,062
  • 35
  • 120
  • 170
  • Possible duplicate of http://stackoverflow.com/questions/620376/how-do-you-find-all-implementations-of-an-interface – Steve Chambers Apr 25 '13 at 15:02
  • So it appears that currently (without buying add ons) this is not possible in Visual Studio. This is a very expensive tool and yet it lacks this helpful feature. I don't get why people are so in love with Visual Studio. – jcollum Nov 14 '14 at 17:54

4 Answers4

8

Using VS2010, with Productivity Power Tools (free) installed:

  1. Leave debug mode if necessary
  2. Hover over a reference to the interface
  3. Expand the drop down that appears
  4. "Implemented By"
sennett
  • 8,014
  • 9
  • 46
  • 69
4

Reflector (which used to be free) will show you this; load the dll and find the interface (F3) - expand the "Derived Types" node.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
2

Why not just search in the entire solution for this:

\:.*MyInterface

and enable regular expressions in the search box - that ought to do the job.

Edit: Fixed the regex, it was for java before, whoops.

Steffen
  • 13,648
  • 7
  • 57
  • 67
  • Not in C#; and there isn't a simple yet reliable version of : IMyInterface - it could be : SomeClass, IMyInterface | : SomeClass, ISomethingElse, IMyInterface, : SomeClass where T : IMyInterface, etc – Marc Gravell Jun 04 '09 at 18:50
  • IMyInterface was just an example - as SkippyFire says he has an interface, I presume he has a specific interface, and thus a name for it. The regex search really should work, it works for me in Visual Studio 2008. I've just edited the expression, as the other one was for Java - my bad. – Steffen Jun 04 '09 at 19:07
  • Sorry for the many comments, I totally misread your comment, and I can see be re-reading it, that you have a good point. However the regex is sound enough for SomeClass: ISomething, IMyInterface But with generic constraints we have a problem. It could easily be done, if visual studio implemented a proper regex engine for search'n'replace, but alas it doesn't :-( – Steffen Jun 04 '09 at 19:19
1

Using the "Go to Inheritor" feature in Resharper or a similar plugin would do the trick.

PHeiberg
  • 29,411
  • 6
  • 59
  • 81