How do you quickly find the implementation(s) of an interface's method? [duplicate]

折月煮酒 提交于 2019-11-27 11:17:14

Since I don't like to use the mouse while coding, I usually

  • move the cursor over the method
  • type ctrl+k clrl+t to open the Call Hierarchy window
  • move down to Implements node.
  • type Return to go to the selected implementation

AFAIK this is the quickest way to find the implementation of a method, without ReSharper.

(By the way: you can use the same system to move from a class method implementation to the corresponding interface declaration: just select the root)

lance

Alt-End will do this in ReSharper, I believe.

Without ReSharper the best way to do this is:

Find in files (Ctrl+Shift+F) Find What: "class*ISomeClass" Find Options: "Use Wildcards"

This will find all implementation and than you can search for your function in a concrete implementation.

If your interface is in the same library as your concrete model that you'll typically want to navigate to, you could add a 'using alias' to the concrete object. 'Usings' are helpers anyhow, and this helps.

using System;
using PrimaryImplementation = YourNamespace.YourConcreteObject;


public interface IYourInterface{

}

When you're taken to the interface, you have a quick (and dirty) way of getting to the primary implementation of your interface. F12->F12!

R# has a Go to Implementation option on the pop-up menu, which is really handy for that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!