Mong Zhu
Mong Zhu

Reputation: 23732

Jump to method signature from code inside the method, or find out in which method the cursor is currently

I am doing reverse engineering of code that someone else wrote. When I search for all references of a variable or method and click on one of the results it beams my cursor right away on the line of code where it is used (which is a brilliant feature). Visual Studio shows me the class where this variable or method is used but not the method. The problem is that sometimes I end up in a huge method deep within, and the only thing I really need is the name of this cursed method.

Question: Is there a simple way to jump to the signature of the method in which the cursor is situated? Or any other way to find it out? (Besides scrolling dozens of pages of code upwards and likely missing it)

Upvotes: 1

Views: 375

Answers (2)

Andrea
Andrea

Reputation: 12355

In Visual Studio 2015 on the top right of the code editing window there's a drop-down list that contains all methods in the current file:

enter image description here

When you move from one method to another inside a file, the selected item in this drop-down list is updated accordingly.

Therefore if you put the cursor in the middle of a method the drop-down list should automatically change the selected item matching the method you're in.

Now if you open the drop-down list and select the current method it should take you to the method's signature.

Upvotes: 3

Mong Zhu
Mong Zhu

Reputation: 23732

Following the advice by Andrea I did a little research. Combined with this answer the outcome is this shortcut series:

Press Cntrl + F2 this will shift the focus to the dropdown menues above the code.

press 2 times Tab which will navigate to the dropdown menue for class elements as @Andrea suggested,

and hit ENTER to confirm the selection, which will automatically jump with the cursor to the signature of the method!

Upvotes: 3

Related Questions