From 6a50430d593225559d866ad7921b94d1e689cc88 Mon Sep 17 00:00:00 2001 From: Christian Pfeiffer Date: Sat, 27 Jun 2026 00:41:01 +0200 Subject: [PATCH] Remove redundant check from Start-EditorServices 6f76c6e319e5245f3d235b35f68329b6067aa120 introduced a correct change to the ValidateSet, but added a redundant check that is already handled in `StartEditorServicesCommand.cs` in its `StartLogging()` routine. In fact, exchanging the values in Start-EditorServices will suppress the warning about the old PSES log levels that `StartLogging()` would normally emit. However, the check is actually harmful on top of this issue since it doesn't check if LogLevel is even set. If LogLevel is `$null`, then the default option ``` default { $LogLevel } ``` isn't valid PowerShell anymore: ``` The variable cannot be validated because the value $null is not a valid value for the LogLevel variable. ``` --- .../Start-EditorServices.ps1 | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/module/PowerShellEditorServices/Start-EditorServices.ps1 b/module/PowerShellEditorServices/Start-EditorServices.ps1 index c61503c65..7536635d9 100644 --- a/module/PowerShellEditorServices/Start-EditorServices.ps1 +++ b/module/PowerShellEditorServices/Start-EditorServices.ps1 @@ -49,9 +49,9 @@ param( [ValidateSet("Diagnostic", "Verbose", "Normal", "Warning", "Error", "Trace", "Debug", "Information", "Critical", "None")] $LogLevel, - [ValidateNotNullOrEmpty()] - [string] - $SessionDetailsPath, + [ValidateNotNullOrEmpty()] + [string] + $SessionDetailsPath, [switch] $EnableConsoleRepl, @@ -107,13 +107,5 @@ param( $DebugServiceOutPipeName ) -#Translate legacy PSES log levels to MEL levels -$LogLevel = switch ($LogLevel) { - 'Diagnostic' { 'Trace' } - 'Verbose' { 'Debug' } - 'Normal' { 'Information' } - default { $LogLevel } -} - Import-Module -Name "$PSScriptRoot/PowerShellEditorServices.psd1" Start-EditorServices @PSBoundParameters