dotnet / razor

Compiler and tooling experience for Razor ASP.NET Core apps in Visual Studio, Visual Studio for Mac, and VS Code.
https://asp.net
MIT License
505 stars 196 forks source link

Feature: Go To Definition For Tag Helpers (and View Components) #6440

Open seangwright opened 2 years ago

seangwright commented 2 years ago

Is your feature request related to a problem? Please describe.

Finding the source of a Tag Helper (or View Component Tag Helper) is very difficult in a Razor view.

For Tag Helpers here is the process I go through to 'go to definition':

For Tag Helper View Components I do the following:

Describe the solution you'd like

When I put my cursor on a Tag Helper element/attribute (or View Component) in my Razor view, I can then type F12 and be taken to the definition, either in source code of my project or the type information from an assembly/package.

Applicable Scenarios Whenever I use Tag Helpers or View Components. So, basically every time I do any server-side HTML rendering with Razor, which is going to be every app I work on.

Describe alternatives you've considered

The alternatives are explained above.

Additional context

There was an issue opened requesting this (https://github.com/dotnet/razor-tooling/issues/5586), but it was closed and marked as a duplicate. Unfortunately, it was incorrectly marked as a duplicate since the "duplicate" was for Blazor.

This seems to be the trend of things in ASP.NET Core. Anything related to Razor is assumed to be in the context of Blazor. Those of us doing server side HTML rendering with Tag Helpers and View Components are "last year's model" and have to wait for features to trickle down 😢.

davidwengier commented 2 years ago

@seangwright Thanks for opening the issue. Would you mind sharing which version of Visual Studio you're using? Also, could you provide some detail of where the tag helpers/components are coming from?

F12 should work for tag helpers defined in the same project, which is I suspect is why the issue you linked is closed. Going to the definition of tag helpers that are defined in other references is indeed a feature gap, tracked by https://github.com/dotnet/razor-tooling/issues/4442

seangwright commented 2 years ago

Visual Studio:

Microsoft Visual Studio Professional 2022 (64-bit) - Current
Version 17.2.2

Tag Helpers that are coming from both external libraries as NuGet packages and within the same project as the Razor file using them.

Here's a screenshot of me hovering over an attribute tag helper (from the same ASP.NET Core 6.0 project as the Razor file). The tooltip works fine, but placing my cursor on the attribute and hitting F12 does nothing.

image

Here's a screenshot of me hovering over a View Component tag helper (from the same ASP.NET Core 6.0 project as the Razor file). Again, the tooltip works fine, but F12 does nothing.

image

Again, these are ASP.NET Core Tag Helpers, not Blazor components. Does the Razor tooling treat these the same?

davidwengier commented 2 years ago

Does the Razor tooling treat these the same?

Generally speaking, yes, we don't make much distinction between .cshtml and .razor files here. Thank you for the extra info though, it's very helpful!