vscode-csharp
vscode-csharp copied to clipboard
Extension stops indexing .razor (Blazor) component files after a certain number unless you open the file.
Issue Description
I think I finally found the main issue preventing me from using VS Code.
I have dotnet.backgroundAnalysis.compilerDiagnosticsScope
and dotnet.backgroundAnalysis.analyzerDiagnosticsScope
both set to fullSolution
and csharp.maxProjectFileCountForDiagnosticAnalysis
set to 9999999999. However it appears that the extension ignores this setting for razor files. After a certain number of razor files, you end up with tons of "Found markup element with unexpected name "SomeComponent" errors until you go open SomeComponent.razor
Steps to Reproduce
- Clone my test repo here.
git clone -b test-large-solution https://github.com/TrieBr/blazor-input-bug.git
-
Open
BlazorInputBug/InputBug/Pages/Counter.razor
. Notice that "InputTextFour" is underlined and an error showsFound markup element with unexpected name 'InputTextFour'. If this is intended to be a component, add a @using directive for its namespace.
. NOTE: Sometimes (flaky) it does work, but you can rename the component to something else likeInputTextFive
orInputTextSix
and observe the same behavior. -
Open
BlazorInputBug/InputBug/Shared/Inputs/InputTextFour.razor
. Then go back toBlazorInputBug/InputBug/Pages/Counter.razor
and observe the problem goes away. -
Delete most of the other files (
BlazorInputBug/InputBug/Shared/Inputs/InputText{11..50.razor}
) and command pallete => reload the window. The problem goes away. You can change betweenInputTextTwo
,InputTextThree
,InputTextFour
, etc and they all work. -
Re-add more files (
for i in {11..50}; do cp InputText.razor "InputText$i.razor"; done
, reload the window and see the problem comes back. You change betweenInputTextTwo
,InputTextThree
,InputTextFour
, etc and is starts to say "Found markup element with unexpected name"
Expected Behavior
When dotnet.backgroundAnalysis.compilerDiagnosticsScope is set to fullSolution
, all razor files should be indexed, and I shouldn't have to go open the ".razor" file to get rid of reference errors.
Actual Behavior
After enough razor files in the solution (my tests seem to break at only 50, but i didn't bisect a smaller number). Intellesense stop working for Blazor components
Logs
C# log
https://pastebin.com/xwDQQM8k
C# LSP Trace Logs
https://pastebin.com/KrCEXRNw
Like https://github.com/dotnet/vscode-csharp/issues/6852, seems like our closed file support might have stopped working.
Hmm. I think I'm seeing this too. I just created a new Blazor server app using the dotnet CLI and the PageTitle
component, along with all the other components referenced in the _Imports.razor
file all highlight as red, unrecognized tags.