Go to override method definition in Visual Studio
Asked Answered
R

4

5

I guess there's no built-in funcionality in Visual Studio for this purpose, but I would be happy if someone could direct me to (free one, if possible) extension that can do this.

    public class Program
{
    static void Main(string[] args)
    {
        Annoy annoy = new Tubo();
        annoy.DoTubo();
    }
}

public class Annoy
{
    public virtual void DoTubo()
    {
        Console.WriteLine("Annoy.DoTubo()");
    }
}

public class Tubo : Annoy
{
    public override void DoTubo()
    {
        Console.WriteLine("Tubo.DoTubo()");
    }
}

When I go with F12 (Go to definition), the carret navigates to Annoy.DoTubo() and not to Tubo.DoTubo().
I've found a plugin for the similar purpose (only for classes impelementing interface and not classes inheriting other classes) here.
I guess ReSharper and VisualAssist has this functionlaity, but I'm looking for a free one if there's any.

Reclaim answered 27/12, 2012 at 15:37 Comment(4)
annoy is declared as an Annoy object; the DoTubbo method is being called from the Annoy class due to the variable declaration. How would VS know to go to the base class?Skewback
@MetroSmurf moreover what if it's Annoy annoy = AnnoyFactory("Tubo");Kaczmarek
@ConradFrix - that would just be annoying...Skewback
what if his object was actually declared as an Tubo? the "go to definition" would still jump to the base class definition. Is there an actual way to navigate to the actual doTubo function that is attached to the object?Carpo
F
12

In Visual Studio 2015, you can use the right-click Context menu on the base method to call "Go to Implementation" which will list out the methods overriding the function declaration.

Freddie answered 6/7, 2016 at 16:42 Comment(1)
This indeed does work in VS Code, in Java at least. In addition, to go to the super (base) class' direction, select go to super implementation. Note this does not have a default hotkey assigned. But you can assign one if you want.Compulsory
P
0

One way to find it without any tool is to look for all references, that'll find the usages of the method.

A free one is the CodeRush by DevExpress

Postdiluvian answered 27/12, 2012 at 15:42 Comment(0)
C
0

As far as I can remember there is build in "Find all references" in Visual Studio's context menu, so there is no need in third party tools

Craze answered 27/12, 2012 at 16:3 Comment(0)
H
0

In Mac: From Definition to Implementation: Cmd+ F12

Hover to read the Definition of Method Implementation.

Humblebee answered 30/3, 2023 at 8:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.