Oftentimes when browsing code, I'll come across something like this:
public class Fruity
{
private IOrange _Orange;
public Fruity()
{
_Orange = new Orange() as IOrange;
}
public void PrepareFruit()
{
return _Orange.Peel();
}
}
Great, so now I want to see how the Peel method is implemented. Right-clicking on the method gives me Go To Definition which takes me to the interface stub.
OK, strictly speaking, the definition is ascribed by the interface given that the private variable is defined in this way, but is there any way to just go to the implementation?
There is of course Find All References which is a scatter-gun approach of calls, interfaces and concretions. But the source of the implementation is obvious in this case so I should be able to jump to it I'd have thought...
Evidently, there can sometimes be ambiguity which is described nicely here:
Go to definition on concrete type
But surely, there should be a Go To Implementation option when the implementation is crystal clear.
Go to Implementation Last modified: 28 October 2021. ReSharper | Navigate | Go to Implementation. Ctrl+F12 ( ReSharper_GotoImplementations ) This command helps you find actual implementations of types and members — in other words, to locate the source code they execute.
If you don't implement all methods of your interface, than you destroy the entire purpose of an interface.
Navigate to implementation of a type or a type memberChoose Navigate | Go To Implementation in the main menu, press Ctrl+F12 , or click the symbol while holding Ctrl+Alt keys. Note that in Visual Studio 2017 and later, the Ctrl+Alt -click is used for adding multiple carets.
Declare the missing methods abstract in your class. This forces you to declare your class abstract and, as a result, forces you to subclass the class (and implement the missing methods) before you can create any objects.
If you double-click or highlight Peel
and press CTRL+,
you'll get the "navigate to symbol" window which will list the actual implementation, usually as the second item. It's about the fastest way of finding it without 3rd party tools. And unlike "find all references", it only shows the method definitions and not wherever it's called.
If you go to the Visual Studio menu "View" and select "Code Definition Window", when you click on .Peel()
you might be shown the implementation of .Peel()
(this doesn't always work, but try it and see).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With