/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ServerConfigurationFactory.cs
59 строк
2 KB
David Barbet
Implement LSP daemon mode (#84199)
25 июл 2026, 00:26
Не верифицирован
25 июл 2026, 00:26
490f516
Код
Авторство
О чём код?
// 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.Composition; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Host.Mef; using Microsoft.CodeAnalysis.Options; using Microsoft.Extensions.Logging; namespace Microsoft.CodeAnalysis.LanguageServer; [Export, Shared] internal sealed class ServerConfigurationFactory { private readonly IGlobalOptionService _globalOptionService; private ServerConfiguration? _serverConfiguration; [ImportingConstructor] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)] public ServerConfigurationFactory(IGlobalOptionService globalOptionService) { _globalOptionService = globalOptionService; } [Export(typeof(ServerConfiguration))] public ServerConfiguration ServerConfiguration => _serverConfiguration ?? throw new InvalidOperationException($"{nameof(ServerConfiguration)} has not been initialized"); public void InitializeConfiguration(ServerConfiguration serverConfiguration) { Contract.ThrowIfFalse(_serverConfiguration == null); _serverConfiguration = serverConfiguration; // Update any other global options based on the configuration the server was started with. // Check if the devkit extension is included to see if devkit is enabled. var isDevkitEnabled = serverConfiguration.DevKitDependencyPath != null; // Set the standalone option so other features know whether devkit is running. _globalOptionService.SetGlobalOption(LspOptionsStorage.LspUsingDevkitFeatures, isDevkitEnabled); } } internal sealed record class ServerConfiguration( bool LaunchDebugger, LogLevel InitialLogLevel, string? TelemetryLevel, string? SessionId, IEnumerable<string> ExtensionAssemblyPaths, string? DevKitDependencyPath, string? CSharpDesignTimePath, string? ServerPipeName, bool UseStdIo, string? ExtensionLogDirectory, int? AutoLoadProjects, SourceGeneratorExecutionPreference SourceGeneratorExecutionPreference, int? ClientProcessId, bool IsDaemon = false, TimeSpan DaemonKeepAlive = default);