From 12afd9c3dded662a91073477abb8c5835aca3f98 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 20 Mar 2017 11:53:43 -0700 Subject: [PATCH] Add initial support for feature flags This change adds initial support for feature flags in the EditorServicesHost so that we can enable new experimental features conditionally while maintaining current behavior for most users. --- .../PowerShellEditorServices/PowerShellEditorServices.psm1 | 7 ++++++- src/PowerShellEditorServices.Host/EditorServicesHost.cs | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/module/PowerShellEditorServices/PowerShellEditorServices.psm1 b/module/PowerShellEditorServices/PowerShellEditorServices.psm1 index 84ee85940..c2ee6cec7 100644 --- a/module/PowerShellEditorServices/PowerShellEditorServices.psm1 +++ b/module/PowerShellEditorServices/PowerShellEditorServices.psm1 @@ -52,6 +52,10 @@ function Start-EditorServicesHost { [string] $DebugServiceOnly, + [string[]] + [ValidateNotNull()] + $FeatureFlags = @(), + [switch] $WaitForDebugger ) @@ -65,7 +69,8 @@ function Start-EditorServicesHost { $hostDetails, $BundledModulesPath, $EnableConsoleRepl.IsPresent, - $WaitForDebugger.IsPresent) + $WaitForDebugger.IsPresent, + $FeatureFlags) # Build the profile paths using the root paths of the current $profile variable $profilePaths = New-Object Microsoft.PowerShell.EditorServices.Session.ProfilePaths @( diff --git a/src/PowerShellEditorServices.Host/EditorServicesHost.cs b/src/PowerShellEditorServices.Host/EditorServicesHost.cs index 363eba04c..43ec42565 100644 --- a/src/PowerShellEditorServices.Host/EditorServicesHost.cs +++ b/src/PowerShellEditorServices.Host/EditorServicesHost.cs @@ -8,6 +8,7 @@ using Microsoft.PowerShell.EditorServices.Session; using Microsoft.PowerShell.EditorServices.Utility; using System; +using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Threading; @@ -33,6 +34,7 @@ public class EditorServicesHost private HostDetails hostDetails; private string bundledModulesPath; private DebugAdapter debugAdapter; + private HashSet featureFlags; private LanguageServer languageServer; #endregion @@ -60,13 +62,15 @@ public EditorServicesHost( HostDetails hostDetails, string bundledModulesPath, bool enableConsoleRepl, - bool waitForDebugger) + bool waitForDebugger, + string[] featureFlags) { Validate.IsNotNull(nameof(hostDetails), hostDetails); this.hostDetails = hostDetails; this.enableConsoleRepl = enableConsoleRepl; this.bundledModulesPath = bundledModulesPath; + this.featureFlags = new HashSet(featureFlags ?? new string[0]); #if DEBUG int waitsRemaining = 10;