diff --git a/.gitignore b/.gitignore index cb12a297984..2c5175a03cf 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/nuget.config b/nuget.config deleted file mode 100644 index 388a65572dd..00000000000 --- a/nuget.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/Modules/nuget.config b/src/Modules/nuget.config deleted file mode 100644 index 388a65572dd..00000000000 --- a/src/Modules/nuget.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/src/System.Management.Automation/engine/SpecialVariables.cs b/src/System.Management.Automation/engine/SpecialVariables.cs index 420b52d4d22..7563f89a919 100644 --- a/src/System.Management.Automation/engine/SpecialVariables.cs +++ b/src/System.Management.Automation/engine/SpecialVariables.cs @@ -341,6 +341,7 @@ internal static class SpecialVariables SpecialVariables.WarningPreference, SpecialVariables.InformationPreference, SpecialVariables.ConfirmPreference, + SpecialVariables.ProgressPreference, }; internal static readonly Type[] PreferenceVariableTypes = @@ -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 diff --git a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs index 8bf14d79aac..504947167b4 100644 --- a/src/System.Management.Automation/engine/parser/VariableAnalysis.cs +++ b/src/System.Management.Automation/engine/parser/VariableAnalysis.cs @@ -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(0, StringComparer.OrdinalIgnoreCase); for (int i = 0; i < orderedLocals.Length; ++i) { diff --git a/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 b/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 index 6f9d80e1677..af7388a418f 100644 --- a/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 +++ b/test/powershell/Language/Scripting/CommonParameters.Tests.ps1 @@ -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 diff --git a/test/tools/Modules/nuget.config b/test/tools/Modules/nuget.config deleted file mode 100644 index 388a65572dd..00000000000 --- a/test/tools/Modules/nuget.config +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - -