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

Extension stops indexing .razor (Blazor) component files after a certain number unless you open the file.

Open TrieBr opened this issue 1 year ago • 3 comments

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

  1. Clone my test repo here.
git clone -b test-large-solution https://github.com/TrieBr/blazor-input-bug.git
  1. Open BlazorInputBug/InputBug/Pages/Counter.razor. Notice that "InputTextFour" is underlined and an error shows Found 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 like InputTextFive or InputTextSix and observe the same behavior.

  2. Open BlazorInputBug/InputBug/Shared/Inputs/InputTextFour.razor. Then go back to BlazorInputBug/InputBug/Pages/Counter.razor and observe the problem goes away.

  3. 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 between InputTextTwo, InputTextThree, InputTextFour, etc and they all work.

  4. 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 between InputTextTwo, 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

Archive.zip

C# log

https://pastebin.com/xwDQQM8k

C# LSP Trace Logs

https://pastebin.com/KrCEXRNw

TrieBr avatar Feb 25 '24 19:02 TrieBr

Like https://github.com/dotnet/vscode-csharp/issues/6852, seems like our closed file support might have stopped working.

davidwengier avatar Feb 26 '24 04:02 davidwengier

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. Screenshot 2024-04-12 at 4 13 32 PM

karanveersp avatar Apr 12 '24 20:04 karanveersp