From b20f7143de1df929e1fd6f1a1bcc888a2067c185 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 15 Sep 2023 11:38:24 -0700 Subject: [PATCH 1/7] Make experimental feature PSConstrainedAuditLogging stable. --- .../engine/ExperimentalFeature/ExperimentalFeature.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index 45f8c98e7a0..fe082993678 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -27,7 +27,6 @@ public class ExperimentalFeature internal const string PSCustomTableHeaderLabelDecoration = "PSCustomTableHeaderLabelDecoration"; internal const string PSFeedbackProvider = "PSFeedbackProvider"; internal const string PSCommandWithArgs = "PSCommandWithArgs"; - internal const string PSConstrainedAuditLogging = "PSConstrainedAuditLogging"; internal const string PSWindowsNativeCommandArgPassing = "PSWindowsNativeCommandArgPassing"; #endregion @@ -138,9 +137,6 @@ static ExperimentalFeature() new ExperimentalFeature( name: PSCommandWithArgs, description: "Enable `-CommandWithArgs` parameter for pwsh"), - new ExperimentalFeature( - name: PSConstrainedAuditLogging, - description: "PowerShell restriction logging when WDAC (Windows Defender Application Control) Code Integrity policy is set to Audit mode."), new ExperimentalFeature( name: "PSWindowsNativeCommandArgPassing", description: "Enable 'Windows' as the native command argument passing mode"), From de0cdacc26de904bf66fe2d1ac21977383cdce39 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 15 Sep 2023 12:14:02 -0700 Subject: [PATCH 2/7] Make experimental feature PSCustomTableHeaderLabelDecoration stable. --- .../FormatAndOutput/common/FormatViewGenerator_Table.cs | 2 +- .../engine/ExperimentalFeature/ExperimentalFeature.cs | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs index 442603b448e..64ed5bad6cf 100644 --- a/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs +++ b/src/System.Management.Automation/FormatAndOutput/common/FormatViewGenerator_Table.cs @@ -173,7 +173,7 @@ private TableHeaderInfo GenerateTableHeaderInfoFromDataBaseInfo(PSObject so) ci.alignment = colHeader.alignment; if (colHeader.label != null) { - ci.HeaderMatchesProperty = so.Properties[colHeader.label.text] is not null || !ExperimentalFeature.IsEnabled(ExperimentalFeature.PSCustomTableHeaderLabelDecoration); + ci.HeaderMatchesProperty = so.Properties[colHeader.label.text] is not null; ci.label = this.dataBaseInfo.db.displayResourceManagerCache.GetTextTokenString(colHeader.label); } diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index fe082993678..0a9868b7732 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -24,7 +24,6 @@ public class ExperimentalFeature internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference"; internal const string PSNativeCommandPreserveBytePipe = "PSNativeCommandPreserveBytePipe"; internal const string PSModuleAutoLoadSkipOfflineFilesFeatureName = "PSModuleAutoLoadSkipOfflineFiles"; - internal const string PSCustomTableHeaderLabelDecoration = "PSCustomTableHeaderLabelDecoration"; internal const string PSFeedbackProvider = "PSFeedbackProvider"; internal const string PSCommandWithArgs = "PSCommandWithArgs"; internal const string PSWindowsNativeCommandArgPassing = "PSWindowsNativeCommandArgPassing"; @@ -125,9 +124,6 @@ static ExperimentalFeature() new ExperimentalFeature( name: PSModuleAutoLoadSkipOfflineFilesFeatureName, description: "Module discovery will skip over files that are marked by cloud providers as not fully on disk."), - new ExperimentalFeature( - name: PSCustomTableHeaderLabelDecoration, - description: "Formatting differentiation for table header labels that aren't property members"), new ExperimentalFeature( name: PSNativeCommandPreserveBytePipe, description: "Byte output is retained when piping between two or more native commands"), From 3889071ae0519962738d34f6659ef2b9206aeefb Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 15 Sep 2023 12:32:13 -0700 Subject: [PATCH 3/7] Make experimental feature PSNativeCommandPreserveBytePipe stable. Left telemetry for use of the feature in. --- .../engine/BytePipe.cs | 4 +- .../ExperimentalFeature.cs | 4 -- .../engine/NativeCommandProcessor.cs | 54 +++++++------------ .../engine/pipeline.cs | 33 +++++------- .../engine/runtime/Operations/MiscOps.cs | 22 +++----- .../Basic/NativeCommandBytePiping.Tests.ps1 | 5 -- 6 files changed, 42 insertions(+), 80 deletions(-) diff --git a/src/System.Management.Automation/engine/BytePipe.cs b/src/System.Management.Automation/engine/BytePipe.cs index 3d4832d6043..03eb827df98 100644 --- a/src/System.Management.Automation/engine/BytePipe.cs +++ b/src/System.Management.Automation/engine/BytePipe.cs @@ -104,9 +104,7 @@ internal static FileBytePipe Create(string fileName, bool append) throw new RuntimeException(null, e, errorRecord); } - ApplicationInsightsTelemetry.SendExperimentalUseData( - ExperimentalFeature.PSNativeCommandPreserveBytePipe, - "f"); + ApplicationInsightsTelemetry.SendExperimentalUseData("PSNativeCommandPreserveBytePipe", "f"); return new FileBytePipe(fileStream); } diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index 0a9868b7732..d71f203a3e8 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -22,7 +22,6 @@ public class ExperimentalFeature internal const string EngineSource = "PSEngine"; internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference"; - internal const string PSNativeCommandPreserveBytePipe = "PSNativeCommandPreserveBytePipe"; internal const string PSModuleAutoLoadSkipOfflineFilesFeatureName = "PSModuleAutoLoadSkipOfflineFiles"; internal const string PSFeedbackProvider = "PSFeedbackProvider"; internal const string PSCommandWithArgs = "PSCommandWithArgs"; @@ -124,9 +123,6 @@ static ExperimentalFeature() new ExperimentalFeature( name: PSModuleAutoLoadSkipOfflineFilesFeatureName, description: "Module discovery will skip over files that are marked by cloud providers as not fully on disk."), - new ExperimentalFeature( - name: PSNativeCommandPreserveBytePipe, - description: "Byte output is retained when piping between two or more native commands"), new ExperimentalFeature( name: PSFeedbackProvider, description: "Replace the hard-coded suggestion framework with the extensible feedback provider"), diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 8a41b22db1d..b2ecaf2e6b6 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -397,8 +397,7 @@ internal override void ProcessRecord() { // If upstream is a native command it'll be writing directly to our stdin stream // so we can skip reading here. - if (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - || !UpstreamIsNativeCommand) + if (!UpstreamIsNativeCommand) { while (Read()) { @@ -720,9 +719,7 @@ private void InitNativeProcess() lock (_sync) { - if (!_stopped - && (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - || !UpstreamIsNativeCommand)) + if (!_stopped && !UpstreamIsNativeCommand) { _inputWriter.Start(_nativeProcess, inputFormat); } @@ -785,21 +782,16 @@ private void InitOutputQueue() if (CommandRuntime.ErrorMergeTo is MshCommandRuntime.MergeDataStream.Output) { StdOutDestination = null; - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe)) + if (DownStreamNativeCommand is not null) { - if (DownStreamNativeCommand is not null) - { - DownStreamNativeCommand.UpstreamIsNativeCommand = false; - DownStreamNativeCommand = null; - } + DownStreamNativeCommand.UpstreamIsNativeCommand = false; + DownStreamNativeCommand = null; } } _nativeProcessOutputQueue = new BlockingCollection(); // we don't assign the handler to anything, because it's used only for objects marshaling - BytePipe stdOutDestination = ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - ? StdOutDestination ?? DownStreamNativeCommand?.CreateBytePipe(stdout: false) - : null; + BytePipe stdOutDestination = StdOutDestination ?? DownStreamNativeCommand?.CreateBytePipe(stdout: false); BytePipe stdOutSource = null; if (stdOutDestination is not null) @@ -822,8 +814,7 @@ private ProcessOutputObject DequeueProcessOutput(bool blocking) { if (blocking) { - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - && _stdOutByteTransfer is not null) + if (_stdOutByteTransfer is not null) { _stdOutByteTransfer.EOF.GetAwaiter().GetResult(); return null; @@ -852,8 +843,7 @@ private ProcessOutputObject DequeueProcessOutput(bool blocking) } else { - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - && _stdOutByteTransfer is not null) + if (_stdOutByteTransfer is not null) { return null; } @@ -896,8 +886,7 @@ internal override void Complete() if (!_isRunningInBackground) { // Wait for input writer to finish. - if (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - || !UpstreamIsNativeCommand) + if (!UpstreamIsNativeCommand) { _inputWriter.Done(); } @@ -1266,8 +1255,7 @@ internal void StopProcessing() if (!_runStandAlone) { // Stop input writer - if (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - || !UpstreamIsNativeCommand) + if (!UpstreamIsNativeCommand) { _inputWriter.Stop(); } @@ -1815,8 +1803,7 @@ public ProcessOutputHandler( return; } - if (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - || stdOutDestination is null) + if (stdOutDestination is null) { _isFirstOutput = true; _isXmlCliOutput = false; @@ -2073,19 +2060,16 @@ internal void Add(object input) object baseObjInput = PSObject.Base(input); - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe)) + if (baseObjInput is byte[] bytes) { - if (baseObjInput is byte[] bytes) - { - _streamWriter.BaseStream.Write(bytes, 0, bytes.Length); - return; - } + _streamWriter.BaseStream.Write(bytes, 0, bytes.Length); + return; + } - if (baseObjInput is byte b) - { - _streamWriter.BaseStream.WriteByte(b); - return; - } + if (baseObjInput is byte b) + { + _streamWriter.BaseStream.WriteByte(b); + return; } AddTextInput(input); diff --git a/src/System.Management.Automation/engine/pipeline.cs b/src/System.Management.Automation/engine/pipeline.cs index a045a4f83ff..e19bf3be843 100644 --- a/src/System.Management.Automation/engine/pipeline.cs +++ b/src/System.Management.Automation/engine/pipeline.cs @@ -261,31 +261,26 @@ private void LogToEventLog() /// internal int Add(CommandProcessorBase commandProcessor) { - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe)) + if (commandProcessor is NativeCommandProcessor nativeCommand) { - if (commandProcessor is NativeCommandProcessor nativeCommand) + if (_lastNativeCommand is not null) { - if (_lastNativeCommand is not null) + // Only report experimental feature usage once per pipeline. + if (!_haveReportedNativePipeUsage) { - // Only report experimental feature usage once per pipeline. - if (!_haveReportedNativePipeUsage) - { - ApplicationInsightsTelemetry.SendExperimentalUseData( - ExperimentalFeature.PSNativeCommandPreserveBytePipe, - "p"); - _haveReportedNativePipeUsage = true; - } - - _lastNativeCommand.DownStreamNativeCommand = nativeCommand; - nativeCommand.UpstreamIsNativeCommand = true; + ApplicationInsightsTelemetry.SendExperimentalUseData("PSNativeCommandPreserveBytePipe", "p"); + _haveReportedNativePipeUsage = true; } - _lastNativeCommand = nativeCommand; - } - else - { - _lastNativeCommand = null; + _lastNativeCommand.DownStreamNativeCommand = nativeCommand; + nativeCommand.UpstreamIsNativeCommand = true; } + + _lastNativeCommand = nativeCommand; + } + else + { + _lastNativeCommand = null; } commandProcessor.CommandRuntime.PipelineProcessor = this; diff --git a/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs index 583288905c2..eb3100ea512 100644 --- a/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs +++ b/src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs @@ -221,10 +221,7 @@ private static CommandProcessorBase AddCommand(PipelineProcessor pipe, bool redirectedInformation = false; if (redirections != null) { - bool shouldProcessMergesFirst = ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe) - && isNativeCommand; - - if (shouldProcessMergesFirst) + if (isNativeCommand) { foreach (CommandRedirection redirection in redirections) { @@ -237,7 +234,7 @@ private static CommandProcessorBase AddCommand(PipelineProcessor pipe, foreach (CommandRedirection redirection in redirections) { - if (!shouldProcessMergesFirst || redirection is not MergingRedirection) + if (!isNativeCommand || redirection is not MergingRedirection) { redirection.Bind(pipe, commandProcessor, context); } @@ -1081,16 +1078,13 @@ public override string ToString() // dir > out internal override void Bind(PipelineProcessor pipelineProcessor, CommandProcessorBase commandProcessor, ExecutionContext context) { - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandPreserveBytePipe)) + if (commandProcessor is NativeCommandProcessor nativeCommand + && nativeCommand.CommandRuntime.ErrorMergeTo is not MshCommandRuntime.MergeDataStream.Output + && FromStream is RedirectionStream.Output + && !string.IsNullOrWhiteSpace(File)) { - if (commandProcessor is NativeCommandProcessor nativeCommand - && nativeCommand.CommandRuntime.ErrorMergeTo is not MshCommandRuntime.MergeDataStream.Output - && FromStream is RedirectionStream.Output - && !string.IsNullOrWhiteSpace(File)) - { - nativeCommand.StdOutDestination = FileBytePipe.Create(File, Appending); - return; - } + nativeCommand.StdOutDestination = FileBytePipe.Create(File, Appending); + return; } Pipe pipe = GetRedirectionPipe(context, pipelineProcessor); diff --git a/test/powershell/engine/Basic/NativeCommandBytePiping.Tests.ps1 b/test/powershell/engine/Basic/NativeCommandBytePiping.Tests.ps1 index 1e645df9030..236cbd8c9e6 100644 --- a/test/powershell/engine/Basic/NativeCommandBytePiping.Tests.ps1 +++ b/test/powershell/engine/Basic/NativeCommandBytePiping.Tests.ps1 @@ -8,11 +8,6 @@ Describe 'Native command byte piping tests' -Tags 'CI' { BeforeAll { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() - if (-not [ExperimentalFeature]::IsEnabled('PSNativeCommandPreserveBytePipe')) - { - $PSDefaultParameterValues['It:Skip'] = $true - return - } # Without this the test would otherwise be hard coded to a specific set # of [Console]::OutputEncoding/$OutputEncoding settings. From 78588755cd8da8812cf482878a3baa8711a1aa82 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 15 Sep 2023 13:29:53 -0700 Subject: [PATCH 4/7] Make experimental feature PSNativeCommandErrorActionPreference stable. Left telemetry for use of the feature in. --- .../ExperimentalFeature/ExperimentalFeature.cs | 4 ---- .../engine/InitialSessionState.cs | 17 +++++++---------- .../engine/NativeCommandProcessor.cs | 10 ++-------- .../Basic/NativeCommandErrorHandling.Tests.ps1 | 6 ------ 4 files changed, 9 insertions(+), 28 deletions(-) diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index d71f203a3e8..c189ab19773 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -21,7 +21,6 @@ public class ExperimentalFeature #region Const Members internal const string EngineSource = "PSEngine"; - internal const string PSNativeCommandErrorActionPreferenceFeatureName = "PSNativeCommandErrorActionPreference"; internal const string PSModuleAutoLoadSkipOfflineFilesFeatureName = "PSModuleAutoLoadSkipOfflineFiles"; internal const string PSFeedbackProvider = "PSFeedbackProvider"; internal const string PSCommandWithArgs = "PSCommandWithArgs"; @@ -117,9 +116,6 @@ static ExperimentalFeature() new ExperimentalFeature( name: "PSLoadAssemblyFromNativeCode", description: "Expose an API to allow assembly loading from native code"), - new ExperimentalFeature( - name: PSNativeCommandErrorActionPreferenceFeatureName, - description: "Native commands with non-zero exit codes issue errors according to $ErrorActionPreference when $PSNativeCommandUseErrorActionPreference is $true"), new ExperimentalFeature( name: PSModuleAutoLoadSkipOfflineFilesFeatureName, description: "Module discovery will skip over files that are marked by cloud providers as not fully on disk."), diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index d367f4eb106..78cbc2a4633 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4652,16 +4652,13 @@ static InitialSessionState() #endregion }; - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandErrorActionPreferenceFeatureName)) - { - builtinVariables.Add( - new SessionStateVariableEntry( - SpecialVariables.PSNativeCommandUseErrorActionPreference, - value: true, // when this feature is changed to stable, this should default to `false` - RunspaceInit.PSNativeCommandUseErrorActionPreferenceDescription, - ScopedItemOptions.None, - new ArgumentTypeConverterAttribute(typeof(bool)))); - } + builtinVariables.Add( + new SessionStateVariableEntry( + SpecialVariables.PSNativeCommandUseErrorActionPreference, + value: true, // when this feature is changed to stable, this should default to `false` + RunspaceInit.PSNativeCommandUseErrorActionPreferenceDescription, + ScopedItemOptions.None, + new ArgumentTypeConverterAttribute(typeof(bool)))); builtinVariables.Add( new SessionStateVariableEntry( diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index b2ecaf2e6b6..373b93fd807 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -940,12 +940,6 @@ internal override void Complete() this.commandRuntime.PipelineProcessor.ExecutionFailed = true; - // Feature is not enabled, so return - if (!ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeCommandErrorActionPreferenceFeatureName)) - { - return; - } - // We send telemetry information only if the feature is enabled. // This shouldn't be done once, because it's a run-time check we should send telemetry every time. // Report on the following conditions: @@ -961,12 +955,12 @@ internal override void Complete() // The variable is unset if (useDefaultSetting) { - ApplicationInsightsTelemetry.SendExperimentalUseData(ExperimentalFeature.PSNativeCommandErrorActionPreferenceFeatureName, "unset"); + ApplicationInsightsTelemetry.SendExperimentalUseData("PSNativeCommandErrorActionPreference", "unset"); return; } // Send the value that was set. - ApplicationInsightsTelemetry.SendExperimentalUseData(ExperimentalFeature.PSNativeCommandErrorActionPreferenceFeatureName, nativeErrorActionPreferenceSetting.ToString()); + ApplicationInsightsTelemetry.SendExperimentalUseData("PSNativeCommandErrorActionPreference", nativeErrorActionPreferenceSetting.ToString()); // if it was explicitly set to false, return if (!nativeErrorActionPreferenceSetting) diff --git a/test/powershell/engine/Basic/NativeCommandErrorHandling.Tests.ps1 b/test/powershell/engine/Basic/NativeCommandErrorHandling.Tests.ps1 index 055382bb5e1..8122e598d2c 100644 --- a/test/powershell/engine/Basic/NativeCommandErrorHandling.Tests.ps1 +++ b/test/powershell/engine/Basic/NativeCommandErrorHandling.Tests.ps1 @@ -7,12 +7,6 @@ Describe 'Native command error handling tests' -Tags 'CI' { BeforeAll { $originalDefaultParameterValues = $PSDefaultParameterValues.Clone() - if (-not [ExperimentalFeature]::IsEnabled('PSNativeCommandErrorActionPreference')) - { - $PSDefaultParameterValues['It:Skip'] = $true - return - } - $exeName = $IsWindows ? 'testexe.exe' : 'testexe' $exePath = @(Get-Command $exeName -Type Application)[0].Path From da4f362eda9a3467135b8bf06f60c05d6a218c01 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 15 Sep 2023 13:50:19 -0700 Subject: [PATCH 5/7] Make experimental feature PSWindowsNativeCommandArgPassing stable. Set default behavior on Window to Legacy. Left telemetry for use of the feature in. --- .../engine/ExperimentalFeature/ExperimentalFeature.cs | 4 ---- .../engine/InitialSessionState.cs | 5 ----- .../engine/NativeCommandProcessor.cs | 2 +- 3 files changed, 1 insertion(+), 10 deletions(-) diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs index c189ab19773..25d9b6e2743 100644 --- a/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs +++ b/src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs @@ -24,7 +24,6 @@ public class ExperimentalFeature internal const string PSModuleAutoLoadSkipOfflineFilesFeatureName = "PSModuleAutoLoadSkipOfflineFiles"; internal const string PSFeedbackProvider = "PSFeedbackProvider"; internal const string PSCommandWithArgs = "PSCommandWithArgs"; - internal const string PSWindowsNativeCommandArgPassing = "PSWindowsNativeCommandArgPassing"; #endregion @@ -125,9 +124,6 @@ static ExperimentalFeature() new ExperimentalFeature( name: PSCommandWithArgs, description: "Enable `-CommandWithArgs` parameter for pwsh"), - new ExperimentalFeature( - name: "PSWindowsNativeCommandArgPassing", - description: "Enable 'Windows' as the native command argument passing mode"), }; EngineExperimentalFeatures = new ReadOnlyCollection(engineFeatures); diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index 78cbc2a4633..d8da9551517 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4682,11 +4682,6 @@ private static NativeArgumentPassingStyle GetPassingStyle() #if UNIX return NativeArgumentPassingStyle.Standard; #else - if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSWindowsNativeCommandArgPassing)) - { - return NativeArgumentPassingStyle.Windows; - } - return NativeArgumentPassingStyle.Legacy; #endif } diff --git a/src/System.Management.Automation/engine/NativeCommandProcessor.cs b/src/System.Management.Automation/engine/NativeCommandProcessor.cs index 373b93fd807..02af209f6ed 100644 --- a/src/System.Management.Automation/engine/NativeCommandProcessor.cs +++ b/src/System.Management.Automation/engine/NativeCommandProcessor.cs @@ -546,7 +546,7 @@ private void InitNativeProcess() // Send Telemetry indicating what argument passing mode we are in. ApplicationInsightsTelemetry.SendExperimentalUseData( - ExperimentalFeature.PSWindowsNativeCommandArgPassing, + "PSWindowsNativeCommandArgPassing", NativeParameterBinderController.ArgumentPassingStyle.ToString()); #if !UNIX From 3c1aaac81dde982a8e05b7d7c3f07e712c4c1d76 Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 18 Sep 2023 16:15:31 -0700 Subject: [PATCH 6/7] Set the proper default value for native argument passing. update the comment for same. --- .../engine/InitialSessionState.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index d8da9551517..eec07f6068c 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4674,15 +4674,14 @@ static InitialSessionState() /// /// Assigns the default behavior for native argument passing. /// If the system is non-Windows, we will return Standard. - /// If the experimental feature is enabled, we will return Windows. - /// Otherwise, we will return Legacy. + /// Otherwise, we will return Windows. /// private static NativeArgumentPassingStyle GetPassingStyle() { #if UNIX return NativeArgumentPassingStyle.Standard; #else - return NativeArgumentPassingStyle.Legacy; + return NativeArgumentPassingStyle.Windows; #endif } From 3a06ab4a00097bf57b5847be34a70e71e3b82dfb Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Thu, 21 Sep 2023 10:42:53 -0700 Subject: [PATCH 7/7] Update src/System.Management.Automation/engine/InitialSessionState.cs Co-authored-by: Steve Lee --- src/System.Management.Automation/engine/InitialSessionState.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index eec07f6068c..0a2d3fa74df 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4655,7 +4655,7 @@ static InitialSessionState() builtinVariables.Add( new SessionStateVariableEntry( SpecialVariables.PSNativeCommandUseErrorActionPreference, - value: true, // when this feature is changed to stable, this should default to `false` + value: false, RunspaceInit.PSNativeCommandUseErrorActionPreferenceDescription, ScopedItemOptions.None, new ArgumentTypeConverterAttribute(typeof(bool))));