Skip to content

Fix LSP duplicate error messages#44874

Merged
allisonchou merged 4 commits intodotnet:masterfrom
allisonchou:DuplicateDiagnosticsLSP
Jun 15, 2020
Merged

Fix LSP duplicate error messages#44874
allisonchou merged 4 commits intodotnet:masterfrom
allisonchou:DuplicateDiagnosticsLSP

Conversation

@allisonchou
Copy link
Contributor

Fixes https://devdiv.visualstudio.com/DevDiv/_queries/edit/1135206/

The Razor language client is publishing diagnostics for non-Razor files on top of the regular C#/VB language client, resulting in duplicate diagnostics.
This is likely because the DocumentPropertiesService.DiagnosticsLspClientName property is only being set when the diagnostic is within a Razor document.
To get around this, if the property is not set, we assume that the diagnostic is within a C#/VB file and thus the diagnostic should only be reported by the C#/VB language client.

@allisonchou allisonchou added Area-IDE LSP issues related to the roslyn language server protocol implementation labels Jun 5, 2020
@allisonchou allisonchou requested review from a team as code owners June 5, 2020 00:57
Copy link
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a bug on the Razor side then? The original design here was we are responsible for publishing our diagnostics; it was only the Razor diagnostics we need to suppress since that was being reported by the Razor provider and not us. If they're asking for diagnostics for regular files and publishing those...can they not do that?

In any case this should target master and not master-vs-deps; there's nothing using VS APIs here.

@dibarbet
Copy link
Member

dibarbet commented Jun 5, 2020

If they're asking for diagnostics for regular files and publishing those...can they not do that?

@jasonmalinowski Since diagnostics are pushed from the server, no one is 'asking' for them per se - the razor c# language server just hears about diagnostic update events from the diagnostic service and publishes them.

So I'd think that the razor C# language server publishes razor diagnostics and only razor diagnostics, and the c# language server publishes diagnostics for only for c# (and not razor c# diagnostics)

@jasonmalinowski
Copy link
Member

Oh, right, forgot this was still push. 😦 So how did this work before? Or did it never properly work? Was Razor filtering the messages before but isn't now?

@allisonchou allisonchou changed the base branch from master-vs-deps to master June 5, 2020 01:56
@allisonchou allisonchou force-pushed the DuplicateDiagnosticsLSP branch from ae39283 to c5f2778 Compare June 5, 2020 18:48
@allisonchou
Copy link
Contributor Author

Hmm, I don't have much background knowledge on the original Razor implementation. @dibarbet do you have any idea?

@dibarbet
Copy link
Member

dibarbet commented Jun 5, 2020

@allisonchou @jasonmalinowski It's very possible it never worked, I don't recall exactly when I started seeing duplicates. Razor couldn't have been filtering, as they cannot intercept push notifications from the server. Could have been some weird interactions where the razor client was not being activated unless a razor file was opened?

@jasonmalinowski jasonmalinowski dismissed their stale review June 12, 2020 00:37

Sounds like nobody knows if this ever worked.

var protocol = ((TestWorkspace)workspace).ExportProvider.GetExportedValue<LanguageServerProtocol>();

var languageServer = new InProcLanguageServer(inputStream, outputStream, protocol, workspace, mockDiagnosticService, clientName: "RazorCSharp");
var languageServer = new InProcLanguageServer(inputStream, outputStream, protocol, workspace, mockDiagnosticService, clientName: null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I talked to David and it's unclear why clientName had a value of RazorCSharp in the first place. I believe these tests should just be using the regular C# language client.

@allisonchou
Copy link
Contributor Author

Quick update - I talked to Taylor earlier today, and he indicated that the fix shouldn't negatively impact anything on the Razor side. The fix appears to be working properly for both C# and Razor files. The original issue likely stems from the ClientName attribute being ignored by Liveshare, so the Razor client always activates.

@allisonchou allisonchou merged commit c2912f6 into dotnet:master Jun 15, 2020
@ghost ghost added this to the Next milestone Jun 15, 2020
@dibarbet dibarbet modified the milestones: Next, 16.7.P4 Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-IDE LSP issues related to the roslyn language server protocol implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants