vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Nested Razor Components showing RZ10012, go to definition not working

Open connelhooley opened this issue 4 years ago • 17 comments

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

connelhooley avatar Nov 29 '20 15:11 connelhooley

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

lonix1 avatar May 03 '22 03:05 lonix1

Placing references in _Imports.razor doesn't help.

lonix1 avatar Oct 02 '22 14:10 lonix1

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

garrettlondon1 avatar Sep 01 '23 13:09 garrettlondon1

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?

jasonmalinowski avatar Sep 01 '23 17:09 jasonmalinowski

@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.

davidwengier avatar Sep 01 '23 23:09 davidwengier

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.

garrettlondon1 avatar Sep 02 '23 04:09 garrettlondon1

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.

davidwengier avatar Sep 02 '23 05:09 davidwengier

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.

ktzsolt avatar Oct 17 '23 14:10 ktzsolt

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.

gulbanana avatar Dec 20 '23 14:12 gulbanana

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.

garrettlondon1 avatar Dec 20 '23 15:12 garrettlondon1

@garrettlondon1 Is that with Omnisharp enabled or disabled?

jasonmalinowski avatar Dec 20 '23 18:12 jasonmalinowski

@garrettlondon1 Is that with Omnisharp enabled or disabled?

Disabled

garrettlondon1 avatar Dec 20 '23 22:12 garrettlondon1

@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)

jasonmalinowski avatar Dec 21 '23 00:12 jasonmalinowski

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

psantosl avatar Jun 07 '24 09:06 psantosl

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

marcos-prins avatar Jun 16 '24 22:06 marcos-prins