Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,6 @@ msbuild.binlog

# Ignore gzip files in the manpage folder
assets/manpage/*.gz
test/tools/Modules/nuget.config
src/Modules/nuget.config
nuget.config
10 changes: 0 additions & 10 deletions nuget.config

This file was deleted.

10 changes: 0 additions & 10 deletions src/Modules/nuget.config

This file was deleted.

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
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,14 @@ orderby details.LocalTupleIndex
(scriptCmdlet ? SpecialVariables.PreferenceVariables.Length : 0),
"analysis is incorrectly allocating number of locals when optimizations are disabled.");

Diagnostics.Assert(SpecialVariables.AutomaticVariables.Length == (int)AutomaticVariable.NumberOfAutomaticVariables
&& SpecialVariables.AutomaticVariableTypes.Length == (int)AutomaticVariable.NumberOfAutomaticVariables,
"automatic variable enum length does not match both automatic variable and automatic variable types length.");

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

var nameToIndexMap = new Dictionary<string, int>(0, StringComparer.OrdinalIgnoreCase);
for (int i = 0; i < orderedLocals.Length; ++i)
{
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 = [Powershell]::Create()
$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 = [Powershell]::Create()
$ps.AddScript(@'
function test-function {
[CmdletBinding()]param()

switch($false) { default {} }

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
10 changes: 0 additions & 10 deletions test/tools/Modules/nuget.config

This file was deleted.

Loading