Roslyn: New Feature Proposal: GoTo Type

Created on 5 May 2015  路  12Comments  路  Source: dotnet/roslyn

Goto Type is similar to goto definition, except it jumps to the definition of the type of the symbol in question instead of the definition of the symbol itself.

For instance:

``` c#
interface ObjectType
{
PropertyType P { get; set; }
}

interface PropertyType
{
void DoStuff();
}

ObjectType obj;
var x = obj.P/Goto type/;
```

To go to the type definition of ObjectType.P you need to two regular goto def jumps, one to the declaration of P and one to its type. This feature has existed in monaco\vs code for a while now, as well as in Eclipse, and IntelliJ IDEA. TypeScript has recently added support for GoTo Type.

Assuming this is not of interest to C#/VB, I propose to enable the front-end support for this along with a key binding to enable TypeScript to expose this feature.

Area-IDE Community Feature Request help wanted

All 12 comments

Apparently VB had this feature in VS 2013, and we never implemented it in Roslyn. :frowning:

It is annoying that this feature is missing from VB.NET in VS2015. Is there a date for the fix?

Being in the "Unknown" milestone, we don't currently have it scheduled for someone on the team to do at all. However, also being Up for grabs means that if a pull request came in to support it, we wouldn't turn it away.

The tricky part is that outside Microsoft it's not actually feasible to deploy changes to VS yet :frowning:, though we hope that changes with Update 1.

I'd be willing to potentially look into this down the line. If anyone wants to tackle this instead though, I'd appreciate a heads up so that we don't end up wasting effort.

I'm going to take a bit of a look at this. It seems like it could be relatively simple - I should be able to copy GoToDefinition, and modify to go to type. This'll be my first look at the Roslyn code, so I could be deluding myself, but we'll see.

No promises on actually achieving anything, so I won't necessarily take ownership of it, not yet at any rate.

Awesome! Thanks! Despite your claim, I'm still going to add the "Grabbed by community" label :smile:

Note that #15286 describes some interesting scenarios where new language features like Tuples mean that it's not always as simple as just going to definition twice...

@Pilchie would it be possible to track down the person on your team who implemented Go To Definition then tell them we would buy them lots of beer if they implemented Go To Type Definition? It's been two years, I upgraded to VS 2017 yesterday and the feature is still missing :-(

I understand though it might be a small request, there's the overhead of productizing it (tests, updating help docs, release notes, etc), so perhaps the "Go To Definition" owner could do an extension and provide it "as is"? Would really appreciate that!

(As a hack, I am currently using the "make explicit" refactoring to add the type name next to a variable declaration, then doing a Go To Definition on the type name, then jumping back and hitting Undo to remove the type name).

@ericmutta - or you could just send us a PR...

@Pilchie you are absolutely right, I just took a peek at the Rosyln Reference Source and it is very neatly organised, I must say, which makes the task of figuring it out less daunting. This open source approach to key parts of Visual Studio is really cool and I figure it's a good investment to start learning the code base and start contributing :-)

As a side note, what is the best venue/method for asking questions about the code when someone is taking baby steps to understand it?

+1 for this feature, which I've been sorely missing for years.

As a side note, what is the best venue/method for asking questions about the code when someone is taking baby steps to understand it?

@ericmutta Sorry this question was missed. There are several avenues you could take. The easiest would likely be to just go to https://gitter.im/dotnet/roslyn to discuss things. Otherwise, you can just open a PR and ask questions in it.

Was this page helpful?
0 / 5 - 0 ratings