razor icon indicating copy to clipboard operation
razor copied to clipboard

Disco colors showing when either VS or language server refer to out-of-date `project.razor.vs.bin`

Open maryamariyan opened this issue 1 year ago • 2 comments

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

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

maryamariyan avatar Jan 06 '24 00:01 maryamariyan