12

Is there a way/tool that could show me all the classes/interfaces that implement a certain interface in my project? In Eclipse (Java) I would use the context menu "Open Type Hierarchy" option, which would show me a (pretty) tree of types that extend the selected type. Is there a tool to do the same in .NET?

Hosam Aly
  • 41,555
  • 36
  • 141
  • 182

7 Answers7

10

I second Marc's recommendation of .NET Reflector - and would like to add that there is an impressive series of add-in available at CodePlex.

Just a few of the add-ins I use with regularity:

  • Deblector - This add-in allows to debug processes from within Reflector.
  • Graph - This add-in draws assembly dependency graphs and IL graphs.
  • DependencyStructureMatrix - Allows you to create and browse dependency structure matrices.
  • AutoDiagrammer - This add-in draws class diagrams.
  • CodeModelViewer - This add-in shows the underlying code model objects for selected items.
Joseph Ferris
  • 12,576
  • 3
  • 46
  • 72
  • 3
    just a note that .NET Reflector is not open source. it's now owned by RedGate and costs $ – ekkis Jul 08 '13 at 21:41
7

The Resharper visual studio plugin also has a View Type Hierarchy feature along with its many other great features.

Mike Two
  • 44,935
  • 9
  • 80
  • 96
  • Resharper certainly looks like a good tool, but it's not free. I come from a Java background, so I'm used to getting all the nice goodies for free. :D – Hosam Aly Dec 21 '08 at 13:55
  • 1
    That's true. I also come from a Java background, and I found that some of the nicer goodies in Java aren't free either. I always preferred the IntelliJ IDE to Eclipse. Sometimes you get what you pay for. Resharper saves me so much time it is worth the money. – Mike Two Dec 21 '08 at 13:58
  • thanks, RightClick -> Inspect ->Type Hierarchy or Ctrl+E, Ctrl+H – Iman Sep 19 '12 at 07:46
4

You can use the Object Browser inside Visual Studio:

The Object Browser lets you select and examine the symbols available for use in projects. You can open the Object Browser from the View menu, or by clicking the Object Browser button on the main toolbar.

In the Objects pane, icons identify hierarchical structures such as .NET Framework and COM components, namespaces, type libraries, interfaces, enums, and classes. You can expand these structures to reveal ordered lists of their members. Properties, methods, events, variables, constants, and other contained items are listed in the Members pane. Details on the item selected in the Objects pane or Members pane appear in the Description pane.

gimel
  • 83,368
  • 10
  • 76
  • 104
  • 3
    But not sub-types / implementing-types – Marc Gravell Dec 21 '08 at 13:25
  • Implementing types can be found using popup->Find All References. – jnnnnn Sep 09 '11 at 01:38
  • A deficiency here is the "Find All References" method doesn't work when the class is part of the .Net language. E.g. right now I'd like to find a class that implements `System.Web.Routing.RouteBase`. Am aware I can go into Internet land to find that out but it would be nice if it were possible within Visual Studio - preferably without having to use a third party tool. – Steve Chambers Apr 24 '13 at 07:18
1

I found this Resharper function handy to show only type hierarchy. Something close to what eclipse offers (F4 - Open type hierarchy) Select parent class then Right click on VS editor and select 'find usages advanced' and select 'derived types' checkbox (or) hit CTRL + ALT + SHIFT F12 to show search properties window

enter image description here

Abdul Jabbar
  • 103
  • 1
  • 5
1

Reflector will do this (and is free). Find the interface, and expand the "Derived Types" node in the tree.

Alternatively, the "Class Diagram" project item in Visual Studio should do it, but I like the clean nature of Reflector.

Marc Gravell
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • To get started, use File->Open... and open your project dll(s) – Marc Gravell Dec 21 '08 at 13:23
  • Reflector did exactly what I needed. Thanks. By the way, the Class Diagram Editor wouldn't have worked for me, because I wanted to check all derived types of a system class. – Hosam Aly Dec 21 '08 at 14:06
  • 3
    [Reflector](http://www.red-gate.com/products/dotnet-development/reflector) may have been free at the time this was written but doesn't look like it is now. – Steve Chambers Apr 24 '13 at 07:20
0

I've just discovered that the option to see derived classes is available in C++ (in Class View), but not in C# in Visual Studio 2008. Wow.

0

Since I was looking for the same in 2018:

Starting from Visual Studio 2015 you can simply install Type Hierarchy Viewer from the Marketplace. This truly isn't as pretty as its eclipse counterpart, but does the job well and is free.

alex3683
  • 1,460
  • 14
  • 25