/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/LanguageServer/Protocol/Handler/SourceGenerators/WorkspaceRefreshSourceGeneratorsHandler.cs
51 строка
2 KB
David Barbet
Make LspWorkspaceRegistrationService a lsp service
13 май 2026, 02:23
13 май 2026, 02:23
0198aff
Код
Авторство
О чём код?
// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Composition; using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CommonLanguageServerProtocol.Framework; using Roslyn.LanguageServer.Protocol; namespace Microsoft.CodeAnalysis.LanguageServer.Handler; /// <summary> /// Handles a request from the client to refresh source generators. /// No specific generators are refreshed; rather, all generators are refreshed in all registered workspaces. /// </summary> [ExportCSharpVisualBasicLspServiceFactory(typeof(WorkspaceRefreshSourceGeneratorsHandler)), Shared] [method: ImportingConstructor] [method: Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] internal sealed class WorkspaceRefreshSourceGeneratorsHandlerFactory() : ILspServiceFactory { public ILspService CreateILspService(LspServices lspServices, WellKnownLspServerKinds serverKind) => new WorkspaceRefreshSourceGeneratorsHandler(lspServices.GetRequiredService<LspWorkspaceRegistrationService>()); } [Method(MethodName)] internal class WorkspaceRefreshSourceGeneratorsHandler(LspWorkspaceRegistrationService workspaceRegistrationService) : ILspServiceNotificationHandler<RefreshSourceGeneratorsParams>, ILspService { public const string MethodName = "workspace/_roslyn_refreshSourceGenerators"; public bool MutatesSolutionState => false; public bool RequiresLSPSolution => false; public Task HandleNotificationAsync(RefreshSourceGeneratorsParams request, RequestContext requestContext, CancellationToken cancellationToken) { foreach (var workspace in workspaceRegistrationService.GetAllRegistrations()) { workspace.EnqueueUpdateSourceGeneratorVersion(projectId: null, request.ForceRegeneration); } return Task.CompletedTask; } } internal record RefreshSourceGeneratorsParams( [property: JsonPropertyName("forceRegeneration")] bool ForceRegeneration );