From 003bbae7049cdb192c6c00e29911aebaea6f7392 Mon Sep 17 00:00:00 2001 From: Heejae Chang Date: Wed, 23 Nov 2016 03:59:42 -0800 Subject: [PATCH] check command line mode before starting solution crawler and remote host. I didn't make whole language service to not start since I wasn't sure end result of such big change. that probably should be done by IDE team. --- .../LanguageService/AbstractPackage`2.cs | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractPackage`2.cs b/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractPackage`2.cs index 067cf3eb815..6551043b7b9 100644 --- a/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractPackage`2.cs +++ b/src/VisualStudio/Core/Def/Implementation/LanguageService/AbstractPackage`2.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; using System.ComponentModel.Design; +using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Packaging; using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.SymbolSearch; @@ -68,7 +69,7 @@ protected override void Initialize() RegisterMiscellaneousFilesWorkspaceInformation(_miscellaneousFilesWorkspace); this.Workspace = this.CreateWorkspace(); - if (this.Workspace != null) + if (IsInIdeMode(this.Workspace)) { // make sure solution crawler start once everything has been setup. // this also should be started before any of workspace events start firing @@ -132,7 +133,7 @@ protected override void Dispose(bool disposing) _miscellaneousFilesWorkspace.StopSolutionCrawler(); } - if (this.Workspace != null) + if (IsInIdeMode(this.Workspace)) { this.Workspace.StopSolutionCrawler(); @@ -151,6 +152,24 @@ protected override void Dispose(bool disposing) protected abstract string RoslynLanguageName { get; } + private bool IsInIdeMode(Workspace workspace) + { + return workspace != null && !IsInCommandLineMode(); + } + + private bool IsInCommandLineMode() + { + var shell = (IVsShell)this.GetService(typeof(SVsShell)); + + object result; + if (ErrorHandler.Succeeded(shell.GetProperty((int)__VSSPROPID.VSSPROPID_IsInCommandLineMode, out result))) + { + return (bool)result; + } + + return false; + } + private void EnableRemoteHostClientService() { ((RemoteHostClientServiceFactory.RemoteHostClientService)this.Workspace.Services.GetService()).Enable(); -- GitLab