Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/community/working-group-definitions.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ The PowerShell developer experience includes the **development of modules** (in
as well as the experience of **hosting PowerShell and its APIs** in other applications and language runtimes.
Special consideration should be given to topics like **backwards compatibility** with Windows PowerShell
(e.g. with **PowerShell Standard**) and **integration with related developer tools**
(e.g. .NET CLI or the PowerShell extension for VS Code).
(e.g. .NET CLI or the PowerShell extension for Visual Studio Code).

### Members

Expand Down
2 changes: 2 additions & 0 deletions src/System.Management.Automation/engine/SpecialVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ internal static class SpecialVariables
SpecialVariables.WarningPreference,
SpecialVariables.InformationPreference,
SpecialVariables.ConfirmPreference,
SpecialVariables.ProgressPreference,
};

internal static readonly Type[] PreferenceVariableTypes =
Expand All @@ -352,6 +353,7 @@ internal static class SpecialVariables
/* WarningPreference */ typeof(ActionPreference),
/* InformationPreference */ typeof(ActionPreference),
/* ConfirmPreference */ typeof(ConfirmImpact),
/* ProgressPreference */ typeof(ActionPreference),
};

// The following variables are created in every session w/ AllScope. We avoid creating local slots when we
Expand Down
8 changes: 8 additions & 0 deletions src/System.Management.Automation/engine/parser/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,14 @@ internal class Compiler : ICustomAstVisitor2

static Compiler()
{
Diagnostics.Assert(SpecialVariables.AutomaticVariables.Length == (int)AutomaticVariable.NumberOfAutomaticVariables
&& SpecialVariables.AutomaticVariableTypes.Length == (int)AutomaticVariable.NumberOfAutomaticVariables,
"The 'AutomaticVariable' enum length does not match both 'AutomaticVariables' and 'AutomaticVariableTypes' length.");

Diagnostics.Assert(Enum.GetNames(typeof(PreferenceVariable)).Length == SpecialVariables.PreferenceVariables.Length
&& Enum.GetNames(typeof(PreferenceVariable)).Length == SpecialVariables.PreferenceVariableTypes.Length,
"The 'PreferenceVariable' enum length does not match both 'PreferenceVariables' and 'PreferenceVariableTypes' length.");

s_functionContext = Expression.Parameter(typeof(FunctionContext), "funcContext");
s_executionContextParameter = Expression.Variable(typeof(ExecutionContext), "context");

Expand Down
38 changes: 38 additions & 0 deletions test/powershell/Language/Scripting/CommonParameters.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,44 @@ Describe "Common parameters support for script cmdlets" -Tags "CI" {
}
}

Context "ProgressAction" {
It "Ignores progress actions on advanced script function with no variables" {
$ps.AddScript(
@'
function test-function {
[CmdletBinding()]param()

Write-Progress "progress foo"
}
test-function -ProgressAction Ignore
'@).Invoke()

$ps.Streams.Progress.Count | Should -Be 0
$ps.Streams.Error | ForEach-Object {
Write-Error -ErrorRecord $_ -ErrorAction Stop
}
}

It "Ignores progress actions on advanced script function with variables" {
$ps.AddScript(
@'
function test-function {
[CmdletBinding()]param([string]$path)

switch($false) { default { "echo $path" } }

Write-Progress "progress foo"
}
test-function -ProgressAction Ignore
'@).Invoke()

$ps.Streams.Progress.Count | Should -Be 0
$ps.Streams.Error | ForEach-Object {
Write-Error -ErrorRecord $_ -ErrorAction Stop
}
}
}

Context "SupportShouldprocess" {
$script = '
function get-foo
Expand Down
Loading