question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't resolve correct blazor component usings/imports

See original GitHub issue

Issue Description

Steps to Reproduce

  1. Create a new dotnet blazor server project (dotnet new blazorserver -o test)
  2. Open the project in Visual Studio Code, with the C# extension installed
  3. Open any file which uses components (such as Shared/MainLayout.razor) and the _Imports.razor file

(Note that this does not happen in Visual Studio 2019)

Expected Behavior

This extension doesn’t show any errors for the generated code

Actual Behavior

All components used in Blazor html markup and in C# @code sections (not present in the generated code) are highlighted in blue or red (info/error) because the extension fails to identify and resolve correct @using directives in the top-level _Imports.razor file

Update

I have disabled all extensions except for the OmniSharp C# one and it is still reporting every single component usage as an error.

Logs

OmniSharp log

OmniSharp log

Starting OmniSharp server at 29.5.2021, 21:14:17
    Target: c:\Users\user\Documents\test\test

OmniSharp server started. Path: c:\Users\user.vscode\extensions\ms-dotnettools.csharp-1.23.12.omnisharp\1.37.10\OmniSharp.exe PID: 11868

    Starting OmniSharp on Windows 6.2.9200.0 (x64)
    DotNetPath set to dotnet
    Located 2 MSBuild instance(s)
        1: Visual Studio Community 2019 16.9.31205.134 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
        2: StandAlone 16.11.0 - "c:\Users\user\.vscode\extensions\ms-dotnettools.csharp-1.23.12\.omnisharp\1.37.10\.msbuild\Current\Bin"
    Registered MSBuild instance: Visual Studio Community 2019 16.9.31205.134 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin"
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Detecting Cake files in 'c:\Users\user\Documents\test\test'.
    Could not find any Cake files
    No solution files found in 'c:\Users\user\Documents\test\test'
    Queue project update for 'c:\Users\user\Documents\test\test\test.csproj'
    Detecting CSX files in 'c:\Users\user\Documents\test\test'.
    Could not find any CSX files
    Configuration finished.
    Omnisharp server running using Stdio at location 'c:\Users\user\Documents\test\test' on host 7776.
    Loading project: c:\Users\user\Documents\test\test\test.csproj
    Successfully loaded project file 'c:\Users\user\Documents\test\test\test.csproj'.
    Adding project 'c:\Users\user\Documents\test\test\test.csproj'
    Update project: test

C# log

C# log

*empty log*

Environment information

VSCode version: 1.56.2 C# Extension: 1.23.12

Dotnet Information .NET SDK: Version: 5.0.202 Commit: db7cc87d51

Runtime: OS Name: Windows OS Version: 10.0.19042 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\5.0.202\

Host (useful for support): Version: 5.0.5 Commit: 2f740adc14

.NET SDKs installed: 3.1.408 [C:\Program Files\dotnet\sdk] 5.0.202 [C:\Program Files\dotnet\sdk]

.NET runtimes installed: Microsoft.AspNetCore.All 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.26 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.27 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.5 [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
aspnetcorerazor-html-css-class-completion kevin-chatham 1.0.3
auto-close-tag formulahendry 0.5.10
auto-complete-tag formulahendry 0.1.0
auto-rename-tag formulahendry 0.1.6
auto-using Fudge 0.7.15
autoimport steoates 1.5.4
blazorwasm-companion ms-dotnettools 1.1.0
bracket-pair-colorizer-2 CoenraadS 0.2.0
browserslist webben 1.1.0
code-spell-checker streetsidesoftware 1.10.2
codespaces GitHub 0.10.4
comment-ts salbert 1.0.21
csharp ms-dotnettools 1.23.12
csharp-colors logerfo 0.1.8
cshtml fireside21 0.1.3
debugger-for-chrome msjsdiag 4.12.12
docfx-assistant tintoy 0.1.5
docomment k–kato 0.1.20
dotenv mikestead 1.0.1
easyzoom NabeelValley 0.1.0
EditorConfig EditorConfig 0.16.4
fluent-icons miguelsolorio 0.0.11
format-selection-as-html adrianwilczynski 2.3.0
git-graph mhutchie 1.30.0
github-markdown-preview bierner 0.0.2
github-vscode-theme GitHub 4.1.1
gitignore codezombiech 0.7.0
gitlens eamodio 11.4.1
headwind heybourn 1.7.0
html-css-class-completion Zignd 1.20.0
html-slim-scss-css-class-completion gencer 1.7.8
JSDocTagComplete HookyQR 0.0.2
markdown-checkbox bierner 0.1.3
markdown-emoji bierner 0.1.0
markdown-preview-github-styles bierner 0.2.0
markdown-yaml-preamble bierner 0.0.4
material-icon-theme PKief 4.7.0
material-product-icons PKief 1.0.4
material-theme zhuangtongfa 3.10.14
npm-intellisense christian-kohler 1.3.1
postcss csstools 1.0.9
prettier-vscode esbenp 6.4.0
quokka-vscode WallabyJs 1.0.369
razor-plus austincummings 0.1.4
remote-containers ms-vscode-remote 0.177.2
remote-wsl ms-vscode-remote 0.56.3
svelte-autoimport pivaszbs 1.0.4
svelte-extractor proverbialninja 0.0.3
svelte-intellisense ardenivanov 0.7.1
svelte-vscode svelte 105.0.0
tailwind-docs austenc 1.4.0
tailwind-sass-syntax macieklad 1.3.0
theme-dracula dracula-theme 2.22.3
vscode-docker ms-azuretools 1.13.0
vscode-dotnet-runtime ms-dotnettools 1.1.0
vscode-eslint dbaeumer 2.1.20
vscode-firefox-debug firefox-devtools 2.9.4
vscode-html-css ecmel 1.10.2
vscode-html-scss P-de-Jong 0.0.42
vscode-language-babel mgmcdermott 0.0.31
vscode-npm-script eg2 0.3.21
vscode-pull-request-github GitHub 0.26.0
vscode-sqlite alexcvzz 0.12.0
vscode-stylelint stylelint 0.86.0
vscode-tailwindcss bradlc 0.6.6
vscode-versionlens pflannery 1.0.9
vscode-yaml redhat 0.19.2
vscodeintellicode VisualStudioExptTeam 1.2.14
zoombar-vscode wraith13 1.4.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
deanchalkcommented, Jun 8, 2021

Hi All, had the same issue. I found a work-around in VS Code by downgrading the C# extension from the current version 1.23.12 to 1.23.11. You can do this in the the extensions panel by clicking on the config button for the C# extension and click ‘Install another version’, then select the previous version. Version 1.23.12 was released about 12 days ago, and obviously has broken razor intellisense

1reaction
Xeeviscommented, Jun 11, 2021

Oddly enough downgrading to 1.23.11 fixed the issue, but then I upgraded back to 1.23.12 and it keeps working. 😵

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core Razor component lifecycle | Microsoft Learn
Component lifecycle events of a Razor component in Blazor. Document Object Model (DOM) event processing: The event handler is run.
Read more >
c# - Component tag does not render blazor ... - Stack Overflow
I an trying to render a blazor component in a razor page. My project is ASP.NET Core Web App. I am primarily using...
Read more >
Editor doesnt recognize blazor component unless the file is ...
In both the preview and retail channel, the blazor editor does not recognize my custom blazor component unless that component file is also...
Read more >
CSS Isolation does not work for Telerik components
CSS Isolation does not work for Telerik components - why Read more in our Blazor Knowledge Base articles. ... New to Telerik UI...
Read more >
Force reload blazor component - Pragim Tech
Force reload blazor nav link. When you are already on EditEmployee component, and when the <NavLink> element is clicked, it does not send...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found