Skip to content
代码片段 群组 项目
未验证 提交 a578d07b 编辑于 作者: Sam Harwell's avatar Sam Harwell 提交者: GitHub
浏览文件

Merge pull request #34793 from sharwell/allow-host-index

:arrow_up_small: Compute indices when OOP is disabled
No related branches found
No related tags found
无相关合并请求
......@@ -139,6 +139,26 @@ public void Disable()
client?.Shutdown();
}
bool IRemoteHostClientService.IsEnabled()
{
// We enable the remote host if either RemoteHostTest or RemoteHost are on.
if (!_workspace.Options.GetOption(RemoteHostOptions.RemoteHostTest)
&& !_workspace.Options.GetOption(RemoteHostOptions.RemoteHost))
{
// not turned on
return false;
}
var remoteHostClientFactory = _workspace.Services.GetService<IRemoteHostClientFactory>();
if (remoteHostClientFactory is null)
{
// not available
return false;
}
return true;
}
public Task<RemoteHostClient> TryGetRemoteHostClientAsync(CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
using Roslyn.Utilities;
......@@ -31,6 +30,11 @@ public RemoteHostClientService(Workspace workspace)
_lazyInstance = CreateNewLazyRemoteHostClient();
}
public bool IsEnabled()
{
return !(_lazyInstance is null);
}
public Task<RemoteHostClient> TryGetRemoteHostClientAsync(CancellationToken cancellationToken)
{
if (_lazyInstance == null)
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Host;
......@@ -12,6 +11,8 @@ namespace Microsoft.CodeAnalysis.Remote
/// </summary>
internal interface IRemoteHostClientService : IWorkspaceService
{
bool IsEnabled();
/// <summary>
/// Request new remote host.
///
......
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Immutable;
using System.Linq;
using Microsoft.CodeAnalysis.Options;
namespace Microsoft.CodeAnalysis.Remote
......@@ -25,6 +23,17 @@ public static bool ShouldComputeIndex(Workspace workspace)
case WorkspaceKind.RemoteWorkspace:
// Always compute indices in the remote workspace.
return true;
case WorkspaceKind.Host:
case WorkspaceKind.MSBuild:
// Compute indices in the host workspace when OOP is disabled.
var remoteHostClientService = workspace.Services.GetService<IRemoteHostClientService>();
if (remoteHostClientService is null)
{
return true;
}
return !remoteHostClientService.IsEnabled();
}
// Otherwise, don't compute the index for any other workspaces.
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册