提交 2ddbe6e6 编写于 作者: H Heejae Chang 提交者: GitHub

Merge pull request #13743 from heejaechang/oopOption

check whether options that require OOP are enabled.
...@@ -5,16 +5,20 @@ ...@@ -5,16 +5,20 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.Shared.Utilities;
using Microsoft.CodeAnalysis.ErrorReporting; using Microsoft.CodeAnalysis.ErrorReporting;
using Microsoft.CodeAnalysis.Execution; using Microsoft.CodeAnalysis.Execution;
using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.Internal.Log;
using Microsoft.CodeAnalysis.Shared.Options;
using Microsoft.VisualStudio.Settings;
using Microsoft.VisualStudio.Shell.Settings;
using Roslyn.Utilities; using Roslyn.Utilities;
namespace Microsoft.VisualStudio.LanguageServices.Remote namespace Microsoft.VisualStudio.LanguageServices.Remote
{ {
internal partial class RemoteHostClientServiceFactory internal partial class RemoteHostClientServiceFactory
{ {
public class RemoteHostClientService : IRemoteHostClientService public class RemoteHostClientService : ForegroundThreadAffinitizedObject, IRemoteHostClientService
{ {
private readonly Workspace _workspace; private readonly Workspace _workspace;
private readonly IDiagnosticAnalyzerService _analyzerService; private readonly IDiagnosticAnalyzerService _analyzerService;
...@@ -25,7 +29,8 @@ public class RemoteHostClientService : IRemoteHostClientService ...@@ -25,7 +29,8 @@ public class RemoteHostClientService : IRemoteHostClientService
private CancellationTokenSource _shutdownCancellationTokenSource; private CancellationTokenSource _shutdownCancellationTokenSource;
private Task<RemoteHostClient> _instanceTask; private Task<RemoteHostClient> _instanceTask;
public RemoteHostClientService(Workspace workspace, IDiagnosticAnalyzerService analyzerService) public RemoteHostClientService(Workspace workspace, IDiagnosticAnalyzerService analyzerService) :
base()
{ {
_gate = new object(); _gate = new object();
...@@ -51,6 +56,12 @@ public void Enable() ...@@ -51,6 +56,12 @@ public void Enable()
return; return;
} }
if (!FeaturesEnabled())
{
// none of features that require OOP is enabled.
return;
}
// log that remote host is enabled // log that remote host is enabled
Logger.Log(FunctionId.RemoteHostClientService_Enabled, KeyValueLogMessage.NoProperty); Logger.Log(FunctionId.RemoteHostClientService_Enabled, KeyValueLogMessage.NoProperty);
...@@ -187,6 +198,44 @@ private void OnConnectionChanged(object sender, bool connected) ...@@ -187,6 +198,44 @@ private void OnConnectionChanged(object sender, bool connected)
// crash right away when connection is closed // crash right away when connection is closed
FatalError.Report(new Exception("Connection to remote host closed")); FatalError.Report(new Exception("Connection to remote host closed"));
} }
private bool FeaturesEnabled()
{
if (ServiceFeatureOnOffOptions.IsClosedFileDiagnosticsEnabled(_workspace.Options, LanguageNames.CSharp))
{
return true;
}
if (TestImpactEnabled())
{
return true;
}
// TODO: add check for code lens.
return false;
}
private bool TestImpactEnabled()
{
const string TestImpactPath = @"CodeAnalysis\TestImpact\IsGloballyEnabled";
const string KeyName = "Value";
// TODO: think about how to get rid of this code. since we don't want any code that require foreground
// thread to run
AssertIsForeground();
var shellSettingsManager = new ShellSettingsManager(Shell.ServiceProvider.GlobalProvider);
var writeableSettingsStore = shellSettingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
if (writeableSettingsStore.PropertyExists(TestImpactPath, KeyName))
{
return writeableSettingsStore.GetBoolean(TestImpactPath, KeyName);
}
else
{
return false;
}
}
} }
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册