Skip to content

Commit 943257b

Browse files
authored
Make some experimental features stable (#26348)
The following experimental features are made stable: - PSNativeWindowsTildeExpansion - PSRedirectToVariable - PSSubsystemPluginModel
1 parent d38d6fa commit 943257b

11 files changed

Lines changed: 37 additions & 84 deletions

File tree

src/Microsoft.PowerShell.Commands.Utility/commands/utility/Var.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,6 @@ public SwitchParameter PassThru
697697
/// Gets whether we will append to the variable if it exists.
698698
/// </summary>
699699
[Parameter]
700-
[Experimental(ExperimentalFeature.PSRedirectToVariable, ExperimentAction.Show)]
701700
public SwitchParameter Append { get; set; }
702701

703702
private bool _nameIsFormalParameter;

src/System.Management.Automation/engine/ExperimentalFeature/ExperimentalFeature.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ public class ExperimentalFeature
2222

2323
internal const string EngineSource = "PSEngine";
2424
internal const string PSFeedbackProvider = "PSFeedbackProvider";
25-
internal const string PSNativeWindowsTildeExpansion = nameof(PSNativeWindowsTildeExpansion);
26-
internal const string PSRedirectToVariable = "PSRedirectToVariable";
2725
internal const string PSSerializeJSONLongEnumAsNumber = nameof(PSSerializeJSONLongEnumAsNumber);
2826

2927
#endregion
@@ -107,21 +105,12 @@ static ExperimentalFeature()
107105
name: "PSFileSystemProviderV2",
108106
description: "Replace the old FileSystemProvider with cleaner design and faster code"),
109107
*/
110-
new ExperimentalFeature(
111-
name: "PSSubsystemPluginModel",
112-
description: "A plugin model for registering and un-registering PowerShell subsystems"),
113108
new ExperimentalFeature(
114109
name: "PSLoadAssemblyFromNativeCode",
115110
description: "Expose an API to allow assembly loading from native code"),
116111
new ExperimentalFeature(
117112
name: PSFeedbackProvider,
118113
description: "Replace the hard-coded suggestion framework with the extensible feedback provider"),
119-
new ExperimentalFeature(
120-
name: PSNativeWindowsTildeExpansion,
121-
description: "On Windows, expand unquoted tilde (`~`) with the user's current home folder."),
122-
new ExperimentalFeature(
123-
name: PSRedirectToVariable,
124-
description: "Add support for redirecting to the variable drive"),
125114
new ExperimentalFeature(
126115
name: PSSerializeJSONLongEnumAsNumber,
127116
description: "Serialize enums based on long or ulong as an numeric value rather than the string representation when using ConvertTo-Json."

src/System.Management.Automation/engine/InitialSessionState.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5478,6 +5478,7 @@ private static void InitializeCoreCmdletsAndProviders(
54785478
{ "Get-Module", new SessionStateCmdletEntry("Get-Module", typeof(GetModuleCommand), helpFile) },
54795479
{ "Get-PSHostProcessInfo", new SessionStateCmdletEntry("Get-PSHostProcessInfo", typeof(GetPSHostProcessInfoCommand), helpFile) },
54805480
{ "Get-PSSession", new SessionStateCmdletEntry("Get-PSSession", typeof(GetPSSessionCommand), helpFile) },
5481+
{ "Get-PSSubsystem", new SessionStateCmdletEntry("Get-PSSubsystem", typeof(Subsystem.GetPSSubsystemCommand), helpFile) },
54815482
{ "Import-Module", new SessionStateCmdletEntry("Import-Module", typeof(ImportModuleCommand), helpFile) },
54825483
{ "Invoke-Command", new SessionStateCmdletEntry("Invoke-Command", typeof(InvokeCommandCommand), helpFile) },
54835484
{ "Invoke-History", new SessionStateCmdletEntry("Invoke-History", typeof(InvokeHistoryCommand), helpFile) },
@@ -5518,11 +5519,6 @@ private static void InitializeCoreCmdletsAndProviders(
55185519
{ "Format-Default", new SessionStateCmdletEntry("Format-Default", typeof(FormatDefaultCommand), helpFile) },
55195520
};
55205521

5521-
if (ExperimentalFeature.IsEnabled("PSSubsystemPluginModel"))
5522-
{
5523-
cmdlets.Add("Get-PSSubsystem", new SessionStateCmdletEntry("Get-PSSubsystem", typeof(Subsystem.GetPSSubsystemCommand), helpFile));
5524-
}
5525-
55265522
#if UNIX
55275523
cmdlets.Add("Switch-Process", new SessionStateCmdletEntry("Switch-Process", typeof(SwitchProcessCommand), helpFile));
55285524
#endif

src/System.Management.Automation/engine/NativeCommandParameterBinder.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,12 +406,9 @@ private void PossiblyGlobArg(string arg, CommandParameterInternal parameter, boo
406406
}
407407
}
408408
#else
409-
if (!usedQuotes && ExperimentalFeature.IsEnabled(ExperimentalFeature.PSNativeWindowsTildeExpansion))
409+
if (!usedQuotes && ExpandTilde(arg, parameter))
410410
{
411-
if (ExpandTilde(arg, parameter))
412-
{
413-
argExpanded = true;
414-
}
411+
argExpanded = true;
415412
}
416413
#endif
417414

src/System.Management.Automation/engine/Subsystem/Commands/GetPSSubsystemCommand.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace System.Management.Automation.Subsystem
88
/// <summary>
99
/// Implementation of 'Get-PSSubsystem' cmdlet.
1010
/// </summary>
11-
[Experimental("PSSubsystemPluginModel", ExperimentAction.Show)]
1211
[Cmdlet(VerbsCommon.Get, "PSSubsystem", DefaultParameterSetName = AllSet)]
1312
[OutputType(typeof(SubsystemInfo))]
1413
public sealed class GetPSSubsystemCommand : PSCmdlet

src/System.Management.Automation/engine/runtime/Operations/MiscOps.cs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,14 +1092,11 @@ internal override void Bind(PipelineProcessor pipelineProcessor, CommandProcesso
10921092
{
10931093
// Check first to see if File is a variable path. If so, we'll not create the FileBytePipe
10941094
bool redirectToVariable = false;
1095-
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSRedirectToVariable))
1095+
1096+
context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(File, out ProviderInfo p, out _);
1097+
if (p != null && p.NameEquals(context.ProviderNames.Variable))
10961098
{
1097-
ProviderInfo p;
1098-
context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(File, out p, out _);
1099-
if (p != null && p.NameEquals(context.ProviderNames.Variable))
1100-
{
1101-
redirectToVariable = true;
1102-
}
1099+
redirectToVariable = true;
11031100
}
11041101

11051102
if (commandProcessor is NativeCommandProcessor nativeCommand
@@ -1223,12 +1220,10 @@ internal Pipe GetRedirectionPipe(ExecutionContext context, PipelineProcessor par
12231220

12241221
// determine whether we're trying to set a variable by inspecting the file path
12251222
// if we can determine that it's a variable, we'll use Set-Variable rather than Out-File
1226-
ProviderInfo p;
1227-
PSDriveInfo d;
12281223
CommandProcessorBase commandProcessor;
1229-
var name = context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(File, out p, out d);
1224+
var name = context.SessionState.Path.GetUnresolvedProviderPathFromPSPath(File, out ProviderInfo p, out _);
12301225

1231-
if (ExperimentalFeature.IsEnabled(ExperimentalFeature.PSRedirectToVariable) && p != null && p.NameEquals(context.ProviderNames.Variable))
1226+
if (p != null && p.NameEquals(context.ProviderNames.Variable))
12321227
{
12331228
commandProcessor = context.CreateCommand("Set-Variable", false);
12341229
Diagnostics.Assert(commandProcessor != null, "CreateCommand returned null");

test/powershell/Language/Parser/RedirectionOperator.Tests.ps1

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ Describe "File redirection should have 'DoComplete' called on the underlying pip
127127
Describe "Redirection and Set-Variable -append tests" -tags CI {
128128
Context "variable redirection should work" {
129129
BeforeAll {
130-
if ( $EnabledExperimentalFeatures -contains "PSRedirectToVariable" ) {
131-
$skipTest = $false
132-
}
133-
else {
134-
$skipTest = $true
135-
}
136130
$testCases = @{ Name = "Variable should be created"; scriptBlock = { 1..3>variable:a }; Validation = { ($a -join "") | Should -Be ((1..3) -join "") } },
137131
@{ Name = "variable should be appended"; scriptBlock = {1..3>variable:a; 4..6>>variable:a}; Validation = { ($a -join "") | Should -Be ((1..6) -join "")}},
138132
@{ Name = "variable should maintain type"; scriptBlock = {@{one=1}>variable:a};Validation = {$a | Should -BeOfType [hashtable]}},
@@ -220,7 +214,7 @@ Describe "Redirection and Set-Variable -append tests" -tags CI {
220214

221215

222216
}
223-
It "<name>" -TestCases $testCases -skip:$skipTest {
217+
It "<name>" -TestCases $testCases {
224218
param ( $scriptBlock, $validation )
225219
. $scriptBlock
226220
. $validation

test/powershell/Language/Scripting/NativeExecution/NativeWindowsTildeExpansion.Tests.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ Describe 'Native Windows tilde expansion tests' -tags "CI" {
55
BeforeAll {
66
$originalDefaultParams = $PSDefaultParameterValues.Clone()
77
$PSDefaultParameterValues["it:skip"] = -Not $IsWindows
8-
$EnabledExperimentalFeatures.Contains('PSNativeWindowsTildeExpansion') | Should -BeTrue
98
}
109

1110
AfterAll {
@@ -21,12 +20,13 @@ Describe 'Native Windows tilde expansion tests' -tags "CI" {
2120
cmd /c echo ~/foo | Should -BeExactly "$($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)/foo"
2221
cmd /c echo ~\foo | Should -BeExactly "$($ExecutionContext.SessionState.Provider.Get("FileSystem").Home)\foo"
2322
}
24-
It '~ should not be replaced when quoted' {
25-
cmd /c echo '~' | Should -BeExactly '~'
26-
cmd /c echo "~" | Should -BeExactly '~'
27-
cmd /c echo '~/foo' | Should -BeExactly '~/foo'
28-
cmd /c echo "~/foo" | Should -BeExactly '~/foo'
23+
24+
It '~ should not be replaced when quoted' {
25+
cmd /c echo '~' | Should -BeExactly '~'
26+
cmd /c echo "~" | Should -BeExactly '~'
27+
cmd /c echo '~/foo' | Should -BeExactly '~/foo'
28+
cmd /c echo "~/foo" | Should -BeExactly '~/foo'
2929
cmd /c echo '~\foo' | Should -BeExactly '~\foo'
30-
cmd /c echo "~\foo" | Should -BeExactly '~\foo'
31-
}
30+
cmd /c echo "~\foo" | Should -BeExactly '~\foo'
31+
}
3232
}

test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Variable.Tests.ps1

Lines changed: 18 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -244,44 +244,30 @@ Describe "Set-Variable" -Tags "CI" {
244244

245245
Context "Set-Variable -Append tests" {
246246
BeforeAll {
247-
if (! (Get-ExperimentalFeature PSRedirectToVariable).Enabled) {
248-
$skipTest = $true
249-
}
250-
251-
$testCases = @{ value = 2; Count = 2 },
252-
@{ value = @(2,3,4); Count = 2},
253-
@{ value = "abc",(Get-Process -Id $PID) ; count = 2}
247+
$testCases = @{ value = 2; Count = 2 },
248+
@{ value = @(2,3,4); Count = 2},
249+
@{ value = "abc",(Get-Process -Id $PID) ; count = 2}
254250
}
255251

256-
It "Can append values <value> to a variable" -testCases $testCases {
257-
param ($value, $count)
258-
259-
if ($skipTest) {
260-
Set-ItResult -skip -because "Experimental Feature PSRedirectToVariable not enabled"
261-
return
262-
}
263-
264-
$variableName = "testVar"
265-
Set-Variable -Name $variableName -Value 1
266-
Set-Variable -Name $variableName -Value $value -Append
252+
It "Can append values <value> to a variable" -testCases $testCases {
253+
param ($value, $count)
267254

268-
$observedValues = Get-Variable $variableName -Value
255+
$variableName = "testVar"
256+
Set-Variable -Name $variableName -Value 1
257+
Set-Variable -Name $variableName -Value $value -Append
269258

270-
$observedValues.Count | Should -Be $count
271-
$observedValues[0] | Should -Be 1
259+
$observedValues = Get-Variable $variableName -Value
272260

273-
$observedValues[1] | Should -Be $value
274-
}
261+
$observedValues.Count | Should -Be $count
262+
$observedValues[0] | Should -Be 1
275263

276-
It "Can use set-variable via streaming and append values" {
277-
if ($skipTest) {
278-
Set-ItResult -skip -because "Experimental Feature PSRedirectToVariable not enabled"
279-
return
280-
}
264+
$observedValues[1] | Should -Be $value
265+
}
281266

282-
$testVar = 1
283-
4..6 | Set-Variable -Name testVar -Append
284-
$testVar | Should -Be @(1,4,5,6)
285-
}
267+
It "Can use set-variable via streaming and append values" {
268+
$testVar = 1
269+
4..6 | Set-Variable -Name testVar -Append
270+
$testVar | Should -Be @(1,4,5,6)
271+
}
286272
}
287273
}

test/powershell/engine/Basic/DefaultCommands.Tests.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@ Describe "Verify aliases and cmdlets" -Tags "CI" {
337337
"Cmdlet", "Get-PSSessionCapability", "", $($FullCLR -or $CoreWindows ), "", "", "None"
338338
"Cmdlet", "Get-PSSessionConfiguration", "", $($FullCLR -or $CoreWindows ), "", "", "None"
339339
"Cmdlet", "Get-PSSnapin", "", $($FullCLR ), "", "", ""
340+
"Cmdlet", "Get-PSSubsystem", "", $( $CoreWindows -or $CoreUnix), "", "", "None"
340341
"Cmdlet", "Get-Random", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "None"
341342
"Cmdlet", "Get-Runspace", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "None"
342343
"Cmdlet", "Get-RunspaceDebug", "", $($FullCLR -or $CoreWindows -or $CoreUnix), "", "", "None"

0 commit comments

Comments
 (0)