-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remap and translate diagnostics on the server #9151
Remap and translate diagnostics on the server #9151
Conversation
@@ -191,6 +192,7 @@ public static void AddDocumentManagementServices(this IServiceCollection service | |||
services.AddSingleton<GeneratedDocumentPublisher, DefaultGeneratedDocumentPublisher>(); | |||
services.AddSingleton<IProjectSnapshotChangeTrigger>((services) => services.GetRequiredService<GeneratedDocumentPublisher>()); | |||
services.AddSingleton<DocumentContextFactory, DefaultDocumentContextFactory>(); | |||
services.AddSingleton(sp => new Lazy<DocumentContextFactory>(sp.GetRequiredService<DocumentContextFactory>)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the annoying way to do lazy DI in this system, and its annoying, but I didn't think it was worth extracting new services and things, because ideally we can move to pull diagnostics in VS Code soon, and then the entire diagnostic publisher can be deleted.
@@ -29,7 +30,6 @@ internal static class CustomMessageNames | |||
public const string RazorResolveCodeActionsEndpoint = "razor/resolveCodeActions"; | |||
public const string RazorProvideHtmlColorPresentationEndpoint = "razor/provideHtmlColorPresentation"; | |||
public const string RazorProvideHtmlDocumentColorEndpoint = "razor/provideHtmlDocumentColor"; | |||
public const string RazorPullDiagnosticEndpointName = "razor/pullDiagnostics"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously VS and VS Code both used this method name, but to my surprise, with different response types. Not strictly an issue since the two systems never exist together, but I thought it would be easier to audit things in future if it wasn't confusing.
@@ -193,8 +209,8 @@ internal async Task PublishDiagnosticsAsync(IDocumentSnapshot document) | |||
{ | |||
var result = await document.GetGeneratedOutputAsync().ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Move this below the if next to where it's used
Server side of dotnet/vscode-csharp#6209
Found an issue in the logs where 2 seconds after a .razor document close, we try to update diagnostics for the document, which then tries to remap the ranges for those diagnostics, but we've just closed the file, the so it fails. This was actually quite wasteful, as the remapping has to happen on the server anyway, so its better to just do it after the results have come back. Additionally, it meant that VS Code diagnostics weren't going through our translation service, which excludes some diagnostics and fixes ranges on others, so the experience would have been generally worse than in VS.
Also renamed a couple of things to make a bit more sense, so the changes are slightly bigger than they first seem.