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
491 stars 190 forks source link

Find All References doesn't work on component type name from C# #6403

Open davidwengier opened 2 years ago

davidwengier commented 2 years ago

Describe the bug: When executing Find All References on a component type in a C# file, we do not navigate to the definition. In < 17.3 P1 Roslyn null-refs (fixed in https://github.com/dotnet/roslyn/pull/61342) but even with that fix, we still fail to show a result, as we fail to map the location Roslyn finds to the Razor document.

Version used: e.g. VS2022 17.3 Preview 1

To reproduce: Steps to reproduce the behavior:

  1. File, New Project, Blazor Server
  2. Open SurveyPrompt.razor
  3. Extract the @code block to a C# file
  4. Right-click on SurveyPrompt class name in the C# file, and click Find All References

Expected behavior: We should show the <SurveyPrompt Title="... from the Index.razor file as a result. We could possibly also show the SurveryPrompt.razor file as a result (possibly already reported as https://github.com/dotnet/razor-tooling/issues/7213)

Actual behavior: Crash/Nothing.

davidwengier commented 2 years ago

Originally reported as https://dev.azure.com/devdiv/DevDiv/_workitems/edit/1537104