问题
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?
回答1:
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.
回答2:
The Resharper visual studio plugin also has a View Type Hierarchy feature along with its many other great features.
回答3:
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.
回答4:
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.
回答5:
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
回答6:
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.
回答7:
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.
来源:https://stackoverflow.com/questions/384406/tool-to-show-class-hierarchies-in-net