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
507 stars 196 forks source link

Navigating to Component within same RCL goes to razor__bg__virtual.cs #9361

Open garrettlondon1 opened 1 year ago

garrettlondon1 commented 1 year ago
image

Navigating to a component in my razor class library with the latest C# extension in VS code (2.4.4), navigates to a razorbgvirtual.cs class, but when hovered over, it is successfully able to resolve the component reference and namespace

Note: Closing and reopening the component leads to the same result

Reloading window leads to same result. Note: this is a newly added component, in the same working session

davidwengier commented 1 year ago

Thanks for the report. This is the same underlying problem that causes https://github.com/dotnet/razor/issues/9369

davidwengier commented 1 year ago

@garrettlondon1 just noticed the "_bg" in the filename. This implies you're using OmniSharp, or have the C# extension set to use OmniSharp at least. Is that correct? Does the problem still exist if you turn that off?

garrettlondon1 commented 1 year ago

Sorry, forgot to mention that.. I had tried three modes of working with the extensions setup:

  1. C# 1.26 - usable but missing important things
  2. C# latest version with Omnisharp enabled - most usable
  3. C# latest version with Omnisharp disabled - completely lose all syntax highlighting, no namespace recognition, cant jump into any references and classes arent recognized.

Also, I do not have the C# dev kit installed, I was having performance issues on my Surface 4 with memory usage. Let me try that again

garrettlondon1 commented 1 year ago

Omnisharp is able to recognize services @injected into the _Imports.razor, and even with C# dev kit I get CS0246 in the code behind file for unrecognized component references, as well as the component tag in the .razor page is unrecognized. Reloading the window, as well as reopening VS code doesn't help

garrettlondon1 commented 1 year ago
image image

Firm is a class, Modal is a component reference, and syntax highlighting is lost with Omnisharp disabled. I even tried restarting the language server, and sorry to jump off topic, but that's why I can't disable Omnisharp. Shoutout dan roth for the searchbox component :)

image

Here is the same with Omnisharp enabled 5 mins later after files were indexed

davidwengier commented 1 year ago

That's not off topic, thats reporting bugs 😁

(though okay.. separate issues is probably ideal, but we'd rather have the information somewhere than not)