Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a "Go To Variable Type Declaration" function for C# in Visual Studio 2015 or a free plugin which does it?

void MagicalFunction(MagicalType magic)
{
    ...
    magic.Poof("something");
    ...
    var foo = magic.GetFoo();
    ...
}

Pressing the hotkey on variable magic would navigate to definition of type MagicalType.

Pressing the hotkey on foo would go to definition of type Foo which is not directly visible here because of type-inference.

Resharper plugin has this functionality (called Go To Type of Symbol) , but is there a built-in alternative or a free-extension that does this?

like image 303
JBeurer Avatar asked Jan 19 '16 05:01

JBeurer


1 Answers

Right click on the "var" keyword, select "Go to definition" from context menu, and it will take you to the type definition of the inferred type of the variable. I have some tools installed, like Productivity Power Tools which were mentioned, so not sure if this option is available through clean VS2015.

Edit:

You can also with cursor on the "var" keyword press Ctrl-F12 (Go to Implementation), if you prefer to use keyboard. Ref: https://www.youtube.com/watch?v=xWcQhF-1hxA

like image 79
Svein Terje Gaup Avatar answered Sep 29 '22 10:09

Svein Terje Gaup