diff --git a/experimental-feature-linux.json b/experimental-feature-linux.json index c25b089125..a71c0c3ed2 100644 --- a/experimental-feature-linux.json +++ b/experimental-feature-linux.json @@ -2,7 +2,6 @@ "PSAnsiRenderingFileInfo", "PSCommandNotFoundSuggestion", "PSLoadAssemblyFromNativeCode", - "PSNativeCommandArgumentPassing", "PSNativeCommandErrorActionPreference", "PSStrictModeAssignment", "PSSubsystemPluginModel" diff --git a/experimental-feature-windows.json b/experimental-feature-windows.json index c25b089125..a71c0c3ed2 100644 --- a/experimental-feature-windows.json +++ b/experimental-feature-windows.json @@ -2,7 +2,6 @@ "PSAnsiRenderingFileInfo", "PSCommandNotFoundSuggestion", "PSLoadAssemblyFromNativeCode", - "PSNativeCommandArgumentPassing", "PSNativeCommandErrorActionPreference", "PSStrictModeAssignment", "PSSubsystemPluginModel" diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index dfb29dfbde..8c3e1c070e 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -21,7 +21,6 @@ namespace System.Management.Automation #region Const Members internal const string EngineSource = "PSEngine"; - internal const string PSNativeCommandArgumentPassingFeatureName = "PSNativeCommandArgumentPassing"; internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference"; internal const string PSStrictModeAssignment = "PSStrictModeAssignment"; @@ -112,9 +111,6 @@ namespace System.Management.Automation new ExperimentalFeature( name: "PSSubsystemPluginModel", description: "A plugin model for registering and un-registering PowerShell subsystems"), - new ExperimentalFeature( - name: PSNativeCommandArgumentPassingFeatureName, - description: "Use ArgumentList when invoking a native command"), new ExperimentalFeature( name: "PSLoadAssemblyFromNativeCode", description: "Expose an API to allow assembly loading from native code"), diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 58cd5f2b3f..e75ca018f8 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4161,13 +4161,7 @@ param( } else { $pagerCommand = 'less' - # PSNativeCommandArgumentPassing arguments should be constructed differently. - if ($EnabledExperimentalFeatures -contains 'PSNativeCommandArgumentPassing') { - $pagerArgs = '-s','-P','Page %db?B of %D:.\. Press h for help or q to quit\.' - } - else { - $pagerArgs = '-Ps""Page %db?B of %D:.\. Press h for help or q to quit\.$""' - } + $pagerArgs = '-s','-P','Page %db?B of %D:.\. Press h for help or q to quit\.' } # Respect PAGER environment variable which allows user to specify a custom pager. @@ -4207,16 +4201,7 @@ param( $consoleWidth = [System.Math]::Max([System.Console]::WindowWidth, 20) if ($pagerArgs) { - # Start the pager arguments directly if the PSNativeCommandArgumentPassing feature is enabled. - # Otherwise, supply pager arguments to an application without any PowerShell parsing of the arguments. - # Leave environment variable to help user debug arguments supplied in $env:PAGER. - if ($EnabledExperimentalFeatures -contains 'PSNativeCommandArgumentPassing') { - $help | Out-String -Stream -Width ($consoleWidth - 1) | & $pagerCommand $pagerArgs - } - else { - $env:__PSPAGER_ARGS = $pagerArgs - $help | Out-String -Stream -Width ($consoleWidth - 1) | & $pagerCommand --% %__PSPAGER_ARGS% - } + $help | Out-String -Stream -Width ($consoleWidth - 1) | & $pagerCommand $pagerArgs } else { $help | Out-String -Stream -Width ($consoleWidth - 1) | & $pagerCommand @@ -4492,16 +4477,13 @@ end { new ArgumentTypeConverterAttribute(typeof(bool)))); } - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandArgumentPassingFeatureName)) - { - builtinVariables.Add( - new SessionStateVariableEntry( - SpecialVariables.NativeArgumentPassing, - Platform.IsWindows ? NativeArgumentPassingStyle.Windows : NativeArgumentPassingStyle.Standard, - RunspaceInit.NativeCommandArgumentPassingDescription, - ScopedItemOptions.None, - new ArgumentTypeConverterAttribute(typeof(NativeArgumentPassingStyle)))); - } + builtinVariables.Add( + new SessionStateVariableEntry( + SpecialVariables.NativeArgumentPassing, + Platform.IsWindows ? NativeArgumentPassingStyle.Windows : NativeArgumentPassingStyle.Standard, + RunspaceInit.NativeCommandArgumentPassingDescription, + ScopedItemOptions.None, + new ArgumentTypeConverterAttribute(typeof(NativeArgumentPassingStyle)))); BuiltInVariables = builtinVariables.ToArray(); } diff --git a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs index aa0e94a583..567a00387d 100644 --- a/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs +++ b/src/System.Management.Automation/engine/NativeCommandParameterBinder.cs @@ -193,23 +193,17 @@ namespace System.Management.Automation { get { - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandArgumentPassingFeatureName)) + try { - try - { - // This will default to the new behavior if it is set to anything other than Legacy - var preference = LanguagePrimitives.ConvertTo( - Context.GetVariableValue(SpecialVariables.NativeArgumentPassingVarPath, NativeArgumentPassingStyle.Standard)); - return preference; - } - catch - { - // The value is not convertable send back Legacy - return NativeArgumentPassingStyle.Legacy; - } + var preference = LanguagePrimitives.ConvertTo( + Context.GetVariableValue(SpecialVariables.NativeArgumentPassingVarPath, NativeArgumentPassingStyle.Standard)); + return preference; + } + catch + { + // The value is not convertable send back Legacy + return NativeArgumentPassingStyle.Legacy; } - - return NativeArgumentPassingStyle.Legacy; } } diff --git a/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 b/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 index 191f7211f6..d96720139b 100644 --- a/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 +++ b/test/powershell/Language/Scripting/NativeExecution/NativeCommandArguments.Tests.ps1 @@ -4,9 +4,6 @@ param() Describe "Behavior is specific for each platform" -tags "CI" { - BeforeAll { - $skipTests = $EnabledExperimentalFeatures -notcontains 'PSNativeCommandArgumentPassing' - } It "PSNativeCommandArgumentPassing is set to 'Windows' on Windows systems" -skip:(-not $IsWindows) { $PSNativeCommandArgumentPassing | Should -Be "Windows" } @@ -28,8 +25,7 @@ Describe "Behavior is specific for each platform" -tags "CI" { Describe "tests for multiple languages and extensions" -tags "CI" { AfterAll { - if (-not $IsWindows -or - $EnabledExperimentalFeatures -notcontains 'PSNativeCommandArgumentPassing') { + if (-not $IsWindows) { return } $PSNativeCommandArgumentPassing = $passingStyle @@ -126,7 +122,7 @@ echo Argument 4 is: ^<%4^> # determine whether we should skip the tests we just defined # doing it in this order ensures that the test output will show each skipped test - $skipTests = -not $IsWindows -or $EnabledExperimentalFeatures -notcontains 'PSNativeCommandArgumentPassing' + $skipTests = -not $IsWindows if ($skipTests) { return } @@ -162,12 +158,7 @@ echo Argument 4 is: ^<%4^> Describe "Will error correctly if an attempt to set variable to improper value" -tags "CI" { It "will error when setting variable incorrectly" { - if ($EnabledExperimentalFeatures -contains 'PSNativeCommandArgumentPassing') { - { $global:PSNativeCommandArgumentPassing = "zzz" } | Should -Throw -ExceptionType System.Management.Automation.ArgumentTransformationMetadataException - } - else { - Set-Test -State skipped -Because "Experimental feature 'PSNativeCommandArgumentPassing' is not enabled" - } + { $global:PSNativeCommandArgumentPassing = "zzz" } | Should -Throw -ExceptionType System.Management.Automation.ArgumentTransformationMetadataException } } @@ -203,7 +194,7 @@ foreach ( $argumentListValue in "Standard","Legacy","Windows" ) { $a = 'a"b c"d' $lines = testexe -echoargs $a 'a"b c"d' a"b c"d "a'b c'd" $lines.Count | Should -Be 4 - if (($EnabledExperimentalFeatures -contains 'PSNativeCommandArgumentPassing') -and $PSNativeCommandArgumentPassing -ne "Legacy") { + if ($PSNativeCommandArgumentPassing -ne "Legacy") { $lines[0] | Should -BeExactly 'Arg 0 is ' $lines[1] | Should -BeExactly 'Arg 1 is ' } @@ -229,7 +220,7 @@ foreach ( $argumentListValue in "Standard","Legacy","Windows" ) { It "Should handle spaces between escaped quotes (ArgumentList=${PSNativeCommandArgumentPassing})" { $lines = testexe -echoargs 'a\"b c\"d' "a\`"b c\`"d" $lines.Count | Should -Be 2 - if (($EnabledExperimentalFeatures -contains 'PSNativeCommandArgumentPassing') -and $PSNativeCommandArgumentPassing -ne "Legacy") { + if ($PSNativeCommandArgumentPassing -ne "Legacy") { $lines[0] | Should -BeExactly 'Arg 0 is ' $lines[1] | Should -BeExactly 'Arg 1 is ' }