未验证 提交 06345198 编写于 作者: C CyrusNajmabadi 提交者: GitHub

Merge pull request #42744 from CyrusNajmabadi/popProvider

Remove the SolutionPopulator incremental analyzer.
......@@ -5,11 +5,11 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Notification;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.CodeAnalysis.Shared.TestHooks;
using Microsoft.CodeAnalysis.SolutionCrawler;
using Microsoft.CodeAnalysis.Text;
using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Remote
......@@ -119,11 +119,36 @@ private void EnqueueChecksumUpdate()
_event.Release();
}
private Task SynchronizePrimaryWorkspaceAsync(CancellationToken cancellationToken)
private async Task SynchronizePrimaryWorkspaceAsync(CancellationToken cancellationToken)
{
return _service.Workspace.SynchronizePrimaryWorkspaceAsync(_service.Workspace.CurrentSolution, cancellationToken);
var workspace = _service.Workspace;
var solution = workspace.CurrentSolution;
if (solution.BranchId != solution.Workspace.PrimaryBranchId)
{
return;
}
var client = await RemoteHostClient.TryGetClientAsync(workspace, cancellationToken).ConfigureAwait(false);
if (client == null)
{
return;
}
using (Logger.LogBlock(FunctionId.SolutionChecksumUpdater_SynchronizePrimaryWorkspace, cancellationToken))
{
var checksum = await solution.State.GetChecksumAsync(cancellationToken).ConfigureAwait(false);
_ = await client.TryRunRemoteAsync(
WellKnownRemoteHostServices.RemoteHostService,
nameof(IRemoteHostService.SynchronizePrimaryWorkspaceAsync),
solution,
new object[] { checksum, solution.WorkspaceVersion },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
}
}
private static void CancelAndDispose(CancellationTokenSource cancellationSource)
{
// cancel running tasks
......
// 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 System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Remote;
using Microsoft.CodeAnalysis.SolutionCrawler;
namespace Microsoft.VisualStudio.LanguageServices.Remote
{
[ExportIncrementalAnalyzerProvider(nameof(RemoteSolutionPopulatorProvider), workspaceKinds: new[] { WorkspaceKind.Host }), Shared]
internal class RemoteSolutionPopulatorProvider : IIncrementalAnalyzerProvider
{
[ImportingConstructor]
public RemoteSolutionPopulatorProvider()
{
}
public IIncrementalAnalyzer CreateIncrementalAnalyzer(Workspace workspace)
{
return new RemoteSolutionPopulator();
}
private class RemoteSolutionPopulator : IncrementalAnalyzerBase
{
public override Task NewSolutionSnapshotAsync(Solution solution, CancellationToken cancellationToken)
{
// this pushes new solution to remote host so that remote host can have new solution get cached before
// anyone actually asking for it. this is for performance rather than functionality.
// since remote host such as Roslyn OOP supports pull mode, any missing data will be automatically pulled to
// remote host when requested if it is not already available in OOP. but by having this, most likely, when
// a feature requests the solution, the solution already exists in OOP due to this pre-emptively pushing the solution
// to OOP. if it already exists in OOP, it will become no-op.
return solution.Workspace.SynchronizePrimaryWorkspaceAsync(solution, cancellationToken);
}
}
}
}
// 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.
#nullable enable
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Internal.Log;
namespace Microsoft.CodeAnalysis.Remote
{
internal static class RemoteHostClientExtensions
{
/// <summary>
/// Synchronize given solution as primary workspace solution in remote host
/// </summary>
public static async Task SynchronizePrimaryWorkspaceAsync(this Workspace workspace, Solution solution, CancellationToken cancellationToken)
{
if (solution.BranchId != solution.Workspace.PrimaryBranchId)
{
return;
}
var client = await RemoteHostClient.TryGetClientAsync(workspace, cancellationToken).ConfigureAwait(false);
if (client == null)
{
return;
}
using (Logger.LogBlock(FunctionId.SolutionChecksumUpdater_SynchronizePrimaryWorkspace, cancellationToken))
{
var checksum = await solution.State.GetChecksumAsync(cancellationToken).ConfigureAwait(false);
_ = await client.TryRunRemoteAsync(
WellKnownRemoteHostServices.RemoteHostService,
nameof(IRemoteHostService.SynchronizePrimaryWorkspaceAsync),
solution,
new object[] { checksum, solution.WorkspaceVersion },
callbackTarget: null,
cancellationToken).ConfigureAwait(false);
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册