Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I "go to definition" for the indexer `this[]` in Visual Studio

I work with a codebase where several classes implement an indexer:

public double this[int i, int j]
{
    get { return ...; }
    set { ...; }
}

When I stumble over code like foo[1,2] = 3 in visual Studio 2008, I frequently want to
right-click / "go to definition", i.e. show the above definition in the visual studio editor window.

For normal properties or methods this works without problems:
foo.bar = 3, right-click / "go to definition" takes me to the source code for foo.bar.
For overloaded + or == this works as well.
However with the indexer this does not seem to work. Is there any way to accomplish this?

(I cannot even search for the string "this[" in the appropriate source file, since the same syntax may be used throughout the class to access the indexer. I always have to scroll trough all the methods and properties in the dropdown list for this file)

like image 411
HugoRune Avatar asked Aug 29 '12 15:08

HugoRune


2 Answers

This doesn't really help with 2008 of course, but in 2010 and above they have "fixed" this with the Navigate To command (ctrl+, in the C# keyboard layout). Where you can enter this to show a list of indexers in the current solution where you can double-click the one you want to navigate to.

+1 for Resharper which seems to work fine with pressing F12 when you caret is within an indexer usage.

like image 77
2 revs, 2 users 80% Avatar answered Oct 04 '22 16:10

2 revs, 2 users 80%


You can install Resharper who give you this functionality, Tool Box productivity don't give this functionality

like image 30
Aghilas Yakoub Avatar answered Oct 04 '22 16:10

Aghilas Yakoub