简体   繁体   中英

Find implementation of interface under cursor in current class

Slightly different versions of this questions don't seem to address my problem, F12/Ctrl-F12 is not what I'm looking for.

When editing a large class that implements an interface defined elsewhere, I'd like to jump to all the places in the file where a function of the interface is implemented:

class VeryLargeClass : IInterfaceInOtherFile
{
  // lots of code

  // ..... I want to jump here
  public FirstFunctionOfIInterfaceInOtherFile() {}

  // more code

  // ..... then I want to jump here
  public SecondFunctionOfIInterfaceInOtherFile() {}
}

Imagine the cursor is on IInterfaceInOtherFile I'd like to find all the places in the current file where IInterfaceInOtherFile is implemented.

Another alternative would be a display mode in ClassView where I can see whether a function in a class is an implemented interface, override from the base class or specific to the class.

Is that possible, maybe with a plugin?

In Visual Studio 2017 (did not test in other versions) you can press Ctrl - F12 or right click on the interface name and choose "Go To Implementation". If there are several implementations, you will get a list of implementations to choose from.

The same mechanism exists for individual properties and methods of the interface.

Note that from an implementation (or anywhere else), you can "Go To Definition" with F12 or through the context menu. With Alt - F12 (or context menu) you can "Peek Definition". Form there you can then go to the implementation(s).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM