From 6a020024ee67993613cc52d2496a79513464b877 Mon Sep 17 00:00:00 2001 From: Manish Vasani Date: Fri, 11 Aug 2023 16:34:48 +0530 Subject: [PATCH] Add BuildOnlyDiagnosticIdsRequest type Work towards #5728. Follow-up to https://github.com/dotnet/roslyn/pull/69475. C# extension can now invoke `getBuildOnlyDiagnosticIds` API after each explicit build/rebuild command to identify build-only diagnostic IDs. --- src/lsptoolshost/roslynLanguageServer.ts | 9 +++++++++ src/lsptoolshost/roslynProtocol.ts | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/lsptoolshost/roslynLanguageServer.ts b/src/lsptoolshost/roslynLanguageServer.ts index 1c17c8d2a..3f6b22db4 100644 --- a/src/lsptoolshost/roslynLanguageServer.ts +++ b/src/lsptoolshost/roslynLanguageServer.ts @@ -712,6 +712,15 @@ export class RoslynLanguageServer { throw new Error(`Invalid log level ${logLevel}`); } } + + public async getBuildOnlyDiagnosticIds(token: vscode.CancellationToken): Promise { + const response = await _languageServer.sendRequest0(RoslynProtocol.BuildOnlyDiagnosticIdsRequest.type, token); + if (response) { + return response.ids; + } + + throw new Error('Unable to retrieve build-only diagnostic ids for current solution.'); + } } /** diff --git a/src/lsptoolshost/roslynProtocol.ts b/src/lsptoolshost/roslynProtocol.ts index a5d4f834c..ec53f7ddc 100644 --- a/src/lsptoolshost/roslynProtocol.ts +++ b/src/lsptoolshost/roslynProtocol.ts @@ -131,6 +131,10 @@ export interface ShowToastNotificationParams { commands: Command[]; } +export interface BuildOnlyDiagnosticIdsResult { + ids: string[]; +} + export namespace WorkspaceDebugConfigurationRequest { export const method = 'workspace/debugConfiguration'; export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer; @@ -192,3 +196,9 @@ export namespace OpenProjectNotification { export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer; export const type = new lsp.NotificationType(method); } + +export namespace BuildOnlyDiagnosticIdsRequest { + export const method = 'workspace/buildOnlyDiagnosticIds'; + export const messageDirection: lsp.MessageDirection = lsp.MessageDirection.clientToServer; + export const type = new lsp.RequestType0(method); +}