简体   繁体   English

转到Visual Studio中的定义 - 接口

[英]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. 如果在方法调用中单击Visual Studio中的F12,则转到其定义。 If its an interface, then you still have to go and look for the class. 如果它是一个接口,那么你仍然需要去寻找这个类。 I would 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... 并且无需安装任何Visual Studio扩展......

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; 如果右键单击该方法并选择“查找所有引用”或按f12 + shift,将在“查找符号结果”中返回实现列表; 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) 安装VS 2015 ,右键单击 - GoToImplementation(如果你有一个接口实现,VS将直接导航到它,如果你有两个或更多,VS会列出它们)

Of course already exists in Visual Studio ! 当然已经存在于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 ??? 为何选择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. 当然,从resharper实现实现并不复杂,它允许在接口上直接询问,但只有属性或来自该接口的方法应该足够了。 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. 右键单击Count属性(任何地方 - 在类内或在界面内)并选择“View Call Hierarchy”,应该说哪个类实现了它,因此应该说是整个接口。

At the beginning we all love Resharper, with time, we all hate it ! 一开始我们都喜欢Resharper,随着时间的推移,我们都讨厌它!

You need to use a plugin that enables it (or write your own). 您需要使用启用它的插件(或编写您自己的插件)。

ReSharper and Visual Assist have this feature. ReSharperVisual Assist具有此功能。

I use the DevExpress/CodeRush Go To Implementator plugin (all free). 我使用DevExpress / CodeRush Go To Implementator插件 (全部免费)。

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: 如果你确实安装了DevExpress它不明显如何启动它,你应该使用shift - ctrl - alt - o键盘短,但我建议通过添加以下注册表项将其添加到文件菜单:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Developer Express\CodeRush for VS\11.2]
"HideMenu"=dword:00000000

(Drop the \\Wow6432Node\\ if you're on 32 bit) (如果您使用32位,请删除\\Wow6432Node\\

另一种方法是将光标放在要调查的方法上,然后按ctrl +,(控制和逗号键)这将显示导航到对话框以及界面和方法实现。

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.) (显然,任何程序集中都可能有一个实现,因此对每个实现进行全面搜索都需要检查每个程序集。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Visual Studio转到定义 - Visual Studio Go to Definition 在Visual Studio中是否与“转到定义”相反? - Is there an opposite to 'go to definition' in Visual Studio? 视觉工作室或Symfony原子:转到定义| 宣言 - visual studio or atom with Symfony : go to definition | declaration 如何在 Visual Studio 中为索引器“this[]”“转到定义” - How do I “go to definition” for the indexer `this[]` in Visual Studio 如何在不使用鼠标单击的情况下在 Visual Studio 中执行“转到定义” - How perform "Go To Definition" in Visual Studio without using mouse click Visual Studio 的“转到定义”转到了错误的函数/行? - Visual Studio's "go to definition" goes to a wrong function/line? 转到定义并查找所有引用在Visual Studio中不起作用 - Go to definition & Find all references do not work in Visual Studio Visual Studio的“转到定义”不适用于JavaScript库 - Visual Studio's 'Go To Definition' doesn't work on javascript libraries 为什么Visual Studio转到未定义的某些变量的定义? - Why does Visual Studio go to the definition of SOME variables that are not defined? Visual Studio 2017 - 转到定义转到 .h 文件而不是 .cpp - Visual Studio 2017 - Go To Definition goes to .h file instead of .cpp
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM