/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/VSCodeSettings.cs
61 строка
2 KB
Joey Robichaud
Update AutoLoad so LSP can read defaultSolution from .vscode/settings.json (#82690)
13 мар 2026, 07:12
Не верифицирован
13 мар 2026, 07:12
30c9b18
Код
Авторство
О чём код?
// 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.Diagnostics.CodeAnalysis; using System.Text.Json; using Microsoft.Extensions.Logging; namespace Microsoft.CodeAnalysis.LanguageServer.HostWorkspace; internal sealed class VSCodeSettings(JsonElement rootElement) { public static bool TryRead(string settingsFilePath, ILogger logger, [NotNullWhen(true)] out VSCodeSettings? settings) { if (File.Exists(settingsFilePath)) { try { var json = File.ReadAllText(settingsFilePath); var options = new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip, }; using var document = JsonDocument.Parse(json, options); if (document.RootElement.ValueKind != JsonValueKind.Object) { settings = null; return false; } settings = new VSCodeSettings(document.RootElement.Clone()); return true; } catch (Exception exception) { logger.LogWarning(exception, "Failed to parse VS Code settings file {SettingsFilePath}.", settingsFilePath); } } settings = null; return false; } public string? TryGetStringSetting(string propertyName) { if (!rootElement.TryGetProperty(propertyName, out var propertyValue) || propertyValue.ValueKind != JsonValueKind.String) { return null; } return propertyValue.GetString(); } public static class Names { public const string DefaultSolution = "dotnet.defaultSolution"; } }