razor
razor copied to clipboard
Disco colors showing when either VS or language server refer to out-of-date `project.razor.vs.bin`
Steps to repro
- change TFM in the project file, and save
- open App.razor and observe disco colors
Summary
This summary explains in a bit more detail a cause for why/when we end up seeing disco color in @ code blocks in razor files.
Latest observations suggest that:
- VS and the language server both rely on project.razor.vs.bin file which gets created in the obj folder.
- disco color bugs happen when VS and language server end up looking at project.razor.vs.bin file in two separate obj folders
- (and when one of the two ends up looking at an out of date / incorrect file)
- With the bug explained in
- Razor Language Server finds old
objfolders to watch, causing issues · Issue #9600 · dotnet/razor (github.com) - which is fixed in PR: https://github.com/dotnet/razor/pull/9601
- with the fix, the language server no longer reads the out-of-date file
- it assumes that VS is updating the new file
- Razor Language Server finds old
But for the current issue,
- knowing that
opening a razor file or creating a new razor component triggers creation or update of project.razor.vs.bin file (when not created yet)
we are noticing that
- once we change target framework in csproj (e.g. from net6 to net8)
- assuming the project.razor.vs.bin file does not exist yet in either net6 or net8 obj Debug folders, then:
- if we open an existing razor file in VS, that causes the file creation in the old obj path
- causing disco colors
- but if we create a new razor file in VS, that causes the file creation in the new obj path
- causing no disco colors
- if we open an existing razor file in VS, that causes the file creation in the old obj path