Go To Definition in Visual Studio - Interfaces
Is there a way to show all classes that implement a certain method from an interface. If you click F12 in Visual Studio on a method call, you go to its definition. If its an interface, then you still have to go and look for the class. I wou开发者_开发百科ld be nice to be able to get a popup and choose one of the classes which implements the interface... Does that exist?
And without installing any Visual Studio extensions...
If you right click the method and select 'find all references' or press f12 + shift a list of implementations will be returned in the Find Symbol Results; ordered by interface, class, method call.
Update
Install VS 2015, right click - GoToImplementation (if you have one implementation for the interface, VS will navigate directly to it, if you have two or more, VS will list them)
You need to use a plugin that enables it (or write your own).
ReSharper and Visual Assist have this feature.
Of course already exists in Visual Studio ! It is there since ever.
Right click on your code (Ex: property) an select "View Call Hierarchy". In Call Hierarchy window select the Implements folder.
There you are. Why Resharper ??? Of course is not that complex as go to implementation from resharper which allows direct interrogation on interface, but only a property, or a method from that interface should be enough. Ex:
public interface IModule
{
int Count { get; set; }
}
public class Module : Imodule
{
public int Count {get; set;}
}
public class Module2 : Imodule
{
public int Count {get; set;}
}
Right click on the Count property (anywhere - inside the class or inside the interface) and select "View Call Hierarchy", should say which class implements it, and therefore the whole Interface.
At the beginning we all love Resharper, with time, we all hate it !
Another alternative is to place your cursor on the method you wish to investigate, then press ctrl + , (control and the comma key) This will display the navigate to dialog with the interface and the method implementation.
I use the DevExpress/CodeRush Go To Implementator plugin (all free).
If you do install DevExpress its not obvious how to launch it, you're supposed to use the shift-ctrl-alt-o keyboard short but I recommend adding it to the file menu by adding the following registry entry:
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Developer Express\CodeRush for VS\11.2]
"HideMenu"=dword:00000000
(Drop the \Wow6432Node\
if you're on 32 bit)
Reflector can do this (at least across the assemblies it has open).
(Clearly there could be an implementation in any assembly, so a full search for every implementation would require checking every assembly.)
精彩评论