Description
Imagine you compile a C# program without a 'main' entrypoint, and it generates the error message
CSC : error CS5001: Program does not contain a static 'Main' method suitable for an entry point [/Users/ljw/code/c/c.csproj]
It's impossible to report this error via LSP! That's because the publishDiagnostics
message has a mandatory uri
field -- but for errors like this, there's no uri
that would make sense! And so the C# plugin for VSCode shows this message in the build output window, but simply doesn't report this error at all to VSCode diagnostics list. @DustinCampbell
I experimented with VSCode behavior:
publishDiagnostics with uri = null
-- this doesn't get shown in the diagnostics window at allpublishDiagnostics with uri = ""
-- this sometimes pops up the Chrome debugger in VSCode, and sometimes crashes VSCode completely with a "report this crash to Apple" system dialog.publishDiagnostics with uri = "file:///"
oruri = "file:///some/directory
-- this shows the error in the diagnostics window, and when you click on it, VSCode does some frenetic flickering of a new document tab before closing it again.
I think that "diagnostics not related to a particular file" are a real fact of life. LSP should be extended to cope with them. And VSCode should too.
My proposal: make the uri
field optional. If it is absent/null, then treat it as a file-less diagnostic, and the range
field inside each individual Diagnostic will be ignored.