dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

Nested Razor Components showing RZ10012, go to definition not working #4250

Open connelhooley opened 4 years ago

connelhooley commented 4 years ago

Issue Description

Blazor components that render other Blazor components have blue squigglies shown under the nested component.

Apologies if this isn't a Omnisharp error. I thought this would have been reported already but a search for "RZ10012" doesn't return any results in the issues of this repo.

Steps to Reproduce

Run:

dotnet new blazorwasm -o BlazorApp1

There will be blue squigglies in some .razor files.

Expected Behavior

Open MainLayout.razor. Line 5 <NavMenu /> shouldn't have a blue squiggly.

Actual Behavior

Open MainLayout.razor. Line 5 <NavMenu /> has a blue squiggly with the following message:

Found markup element with unexpected name 'NavMenu'. If this is intended to be a component, add a @using directive for its namespace.(RZ10012)

Right clicking on <NavMenu /> and clicking on Go to Definition also fails with a definition not found message.

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.51.1 C# Extension: 1.23.6

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.402 Commit: 9b5de826fd Runtime Environment: OS Name: Windows OS Version: 10.0.19041 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.1.402\ Host (useful for support): Version: 5.0.0 Commit: cf258a14b7 .NET SDKs installed: 2.0.0 [C:\Program Files\dotnet\sdk] 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.200 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.300 [C:\Program Files\dotnet\sdk] 2.1.402 [C:\Program Files\dotnet\sdk] 2.1.602 [C:\Program Files\dotnet\sdk] 2.1.700 [C:\Program Files\dotnet\sdk] 2.1.801 [C:\Program Files\dotnet\sdk] 2.2.104 [C:\Program Files\dotnet\sdk] 2.2.108 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk] 3.1.401 [C:\Program Files\dotnet\sdk] 3.1.402 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] To install additional .NET runtimes or SDKs: https://aka.ms/dotnet-download
Visual Studio Code Extensions |Extension|Author|Version| |---|---|---| |azure-account|ms-vscode|0.9.4| |azure-pipelines|ms-azure-devops|1.177.0| |code-spell-checker|streetsidesoftware|1.10.2| |csharp|ms-dotnettools|1.23.6| |csharpextensions|jchannon|1.3.1| |debugger-for-chrome|msjsdiag|4.12.11| |markdown-all-in-one|yzhang|3.4.0| |powershell|ms-vscode|2020.6.0| |remote-containers|ms-vscode-remote|0.148.1| |rest-client|humao|0.24.4| |vscode-docker|ms-azuretools|1.8.1| |vscode-eslint|dbaeumer|2.1.13| |vscode-firefox-debug|firefox-devtools|2.9.1| |vscode-markdownlint|DavidAnson|0.37.2| |vscode-typescript-next|ms-vscode|4.2.20201128| |vscode-yaml|redhat|0.13.0|;
lonix1 commented 2 years ago

Still a problem with the latest version on .NET 6 (using O# "modern" build).

lonix1 commented 2 years ago

Placing references in _Imports.razor doesn't help.

garrettlondon1 commented 1 year ago

@jasonmalinowski What is the status on here? RZ10012 make VS code barely usable

jasonmalinowski commented 1 year ago

Heh, I'm not the expert here, I just had a batch tool that tagged all the old bugs. :smile: @dotnet/razor-tooling any thoughts here?

davidwengier commented 1 year ago

@garrettlondon1 Could you let us know a few more details of your setup? eg, which version of the C# extension you're using? Do you have DevKit installed? Do you have the "Use OmniSharp" setting turned on? Which version of .NET are you using? etc.

The other thing to check is that the project loaded and restore correctly. Sometimes that can be harder to spot, but if you hover your mouse over WebAssemblyHostBuilder in Program.cs do you get the expected tooltip info about the API?

Recent releases of the C# extension have made these project loading issues much more visible, via a popup, so definitely try updating if you can and see if that helps.

garrettlondon1 commented 1 year ago

Hey @davidwengier,

I don't know if its specific to Blazor specifically but the areas I have specifically noticed trouble is with Components in RCL, especially _Imports.razor not working properly with globally injected services and namespaces. Red lines everywhere. Tried all versions of the latest C# extension with the Dev Kit. Solution Explorer is wonderful, problem is the extension uses a crazy amount of memory. Don't think I've tried using OmniSharp setting with new version of C# extension + kit.. but I've downgraded to 1.26 and using OmniSharp and it's an absolute joy. Not that it's anything special but my surface 4 with 16gb RAM couldn't handle a couple chrome tabs and the VS code dev kit. Now my fan doesn't make a sound with the barebones VS code setup and productivity is through the roof.

davidwengier commented 1 year ago

Thanks for the extra info, an RCL is probably the contributing factor that would affect things, and I wouldn't be surprised if there are still bugs around it. Would you mind logging a new issue with a simple repro, since its a different issue to this one, and this is about OmniSharp but you seem to have the opposite experience where OmniSharp works.

Regarding memory, again it would be great for you to log a new issue because there needs to be some investigation into which process is the biggest contributor, between Roslyn, Razor, DevKit etc. Memory dumps or ETL traces would be super helpful for that one, if you can.

ktzsolt commented 1 year ago

Placing references in _Imports.razor doesn't help.

I saw your comment and I went to open _Imports.razor and the errors and warnings immediately went away. I don't use C# DevKit extension because licensing, only the C# extension.

gulbanana commented 11 months ago

just to add a datapoint, i too have a solution containing razor class libraries and blazor web apps; in vscode using c# dev kit, most of it was covered in RZ10012. i disabled the devkit extension and enabled omnisharp, and now everything works.

garrettlondon1 commented 11 months ago
image

Even with regular C# classes, go to definition fails on latest C# extension 2.14.8 @davidwengier. The interface is in the same exact folder as the implementation.

jasonmalinowski commented 11 months ago

@garrettlondon1 Is that with Omnisharp enabled or disabled?

garrettlondon1 commented 11 months ago

@garrettlondon1 Is that with Omnisharp enabled or disabled?

Disabled

jasonmalinowski commented 11 months ago

@garrettlondon1: can you file a new bug on that? That seems like something is broken more directly and we need to investigate why. Please set dotnet.server.trace property to 'trace' and include the C# log too.

(might be there's a root cause that they're related but if nothing else the separate bug would help if I need to ask you for more info for your case)

psantosl commented 5 months ago

Is this still happening, right? I can't use vscode with a blazor project, it detects errors all the time

marcos-prins commented 5 months ago

yes, is still happening. Intellisense is basically broken right now for blazor in vscode Screenshot from 2024-06-16 17-13-27

divieirasilva commented 3 months ago

Yep, still happening!

image
jmlane commented 2 months ago

I was seeing the same issue on VS Code Insiders with C# Dev Kit (v1.10.16, C# extension: v2.45.20).

Toggling to OmniSharp mode in the C# extension and back to full Dev Kit again cleared the warnings and made the tooltip and "Go to Definition" work again.

I will post an update if I can figure out how to replicate the warnings again.