Doesn't resolve correct blazor component usings/imports
See original GitHub issueIssue Description
Steps to Reproduce
- Create a new dotnet blazor server project (
dotnet new blazorserver -o test
) - Open the project in Visual Studio Code, with the C# extension installed
- 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: db7cc87d51Runtime: 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:
- Created 2 years ago
- Reactions:10
- Comments:11 (1 by maintainers)
Top GitHub Comments
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
Oddly enough downgrading to 1.23.11 fixed the issue, but then I upgraded back to 1.23.12 and it keeps working. 😵