/
githubmirror
/
roslyn
Обзор
Документация
Войти
/
githubmirror
/
roslyn
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/LanguageServer/Protocol.TestUtilities/Workspaces/LspTestWorkspace.cs
50 строк
2 KB
Cyrus Najmabadi
Reapply "Update methods to be `async`." (#81808)
31 дек 2025, 21:28
31 дек 2025, 21:28
bc3d228
Код
Авторство
О чём код?
// 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.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.LanguageServer; using Microsoft.CodeAnalysis.Text; using Microsoft.VisualStudio.Composition; namespace Microsoft.CodeAnalysis.Test.Utilities; public sealed partial class LspTestWorkspace : TestWorkspace, ILspWorkspace { private readonly bool _supportsLspMutation; internal LspTestWorkspace( ExportProvider exportProvider, string? workspaceKind = WorkspaceKind.Host, Guid solutionTelemetryId = default, bool disablePartialSolutions = true, bool ignoreUnchangeableDocumentsWhenApplyingChanges = true, WorkspaceConfigurationOptions? configurationOptions = null, bool supportsLspMutation = false) : base(exportProvider, workspaceKind, solutionTelemetryId, disablePartialSolutions, ignoreUnchangeableDocumentsWhenApplyingChanges, configurationOptions) { _supportsLspMutation = supportsLspMutation; } bool ILspWorkspace.SupportsMutation => _supportsLspMutation; async ValueTask ILspWorkspace.UpdateTextIfPresentAsync(DocumentId documentId, SourceText sourceText, CancellationToken cancellationToken) { Contract.ThrowIfFalse(_supportsLspMutation); OnDocumentTextChanged(documentId, sourceText, PreservationMode.PreserveIdentity, requireDocumentPresent: false); } internal override ValueTask TryOnDocumentClosedAsync(DocumentId documentId, CancellationToken cancellationToken) { Contract.ThrowIfFalse(_supportsLspMutation); return base.TryOnDocumentClosedAsync(documentId, cancellationToken); } }