F12-转到接口的实现 [英] F12 - Go to Implementation of Interface

查看:114
本文介绍了F12-转到接口的实现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当不运行应用程序时,在接口类型的方法上按F12(转到定义)将使您进入接口本身.

When not running an application, pressing F12 (Go To Definition) on a method on an interface type will take you to the interface itself.

是否存在任何键组合(或我可以制作的键组合),这些键组合可以让我提供要跳转到的默认实现,或者可以让我快速选择要执行的实现?

Is there any key combo that exists (or one that I can make) that will allow me to provide a default implementation to jump to, or allow me to quickly pick an implementation to go to?

我们的应用程序中包含几层,并且可以直接跳转到MockReal实现,而不是在源代码管理中导航到它们,这将节省大量时间.

We have several layers in our application, and it would save a lot of time to be able to jump straight to the Mock or Real implementations rather than navigating to them in source control.

推荐答案

如果使用VS 2015及更高版本:

请参阅下面的答案:

If using VS 2015 and above:

See answer below:

Visual Studio 2015 Update 1添加了出现在上下文菜单中的Edit.GoToImplementation,但是默认情况下没有与之关联的键盘快捷键.

Visual Studio 2015 Update 1 added Edit.GoToImplementation which appeared in the context menu, but there was no keyboard shortcut associated with it by default.

在Visual Studio Update 2中,我们添加了默认快捷键Ctrl + F12.

In Visual Studio Update 2, we added a default shortcut of Ctrl+F12.


如果使用VS 2013及更低版本:

我们遇到了同样的问题,并开始使用 Resharper .我记得它具有很好的 Goto实现功能,效果很好.

We had the same problem and started using Resharper. It has a nice Goto Implementation feature, which was working very well, as I remember.

问题在于该工具不是免费的(这当然是合理的,因为它提供的功能远远超过了所提到的功能).

The problem is that this tool is not free though (which is of course justified, as it offers much, much more than the mentioned feature).

否则,我将使用查找所有引用,并通过查看路径快速识别实现(我们将接口,实现和模拟很好地隔离开了).但是您可能自己已经确定了这种可能性.

Without this, I use Find All References and identify the implementation quickly by looking at the path (we have interfaces, implementations and mocks nicely segregated). But you've probably identified this possibility by yourself.

此外,您可以考虑在此答案中提及的选项(尽管它用于接口方法,而不是实现):

Also, you may consider an option mentioned in this answer (although it's for interface methods, not implementations):

  • 将光标移到方法上
  • 键入 CTRL + K CTRL + T 打开呼叫层次结构"窗口
  • 向下移动到"实施"节点
  • 键入 Return 进入所选的实现
  • move the cursor over the method
  • type CTRL+K CTRL+T to open the Call Hierarchy window
  • move down to Implements node
  • type Return to go to the selected implementation

这篇关于F12-转到接口的实现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆