[release/v7.4] Fix Progress Preference variable in adv functions#26865
[release/v7.4] Fix Progress Preference variable in adv functions#26865TravisEz13 wants to merge 1 commit intoPowerShell:release/v7.4from
Conversation
…werShell#24591) Co-authored-by: Dongbo Wang <dongbow@microsoft.com>
There was a problem hiding this comment.
Pull request overview
This PR backports a critical bug fix from #24591 to the release/v7.4 branch. The fix addresses an array out-of-bounds error that occurs when using the -ProgressAction common parameter in advanced PowerShell functions. The bug was caused by missing ProgressPreference entries in the PreferenceVariables and PreferenceVariableTypes arrays in SpecialVariables.cs, which caused index mismatches when the compiler tried to map preference variables. The fix adds the missing array entries, includes defensive assertions to prevent similar issues in the future, and adds comprehensive tests to verify the fix.
Changes:
- Added missing
ProgressPreferenceentries to preference variable arrays inSpecialVariables.cs - Added diagnostic assertions in
Compiler.csto detect array/enum mismatches at startup - Added comprehensive tests for
-ProgressActionparameter functionality - Minor documentation improvement (VS Code → Visual Studio Code)
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/System.Management.Automation/engine/SpecialVariables.cs |
Adds missing ProgressPreference entries to PreferenceVariables and PreferenceVariableTypes arrays to fix index mismatch |
src/System.Management.Automation/engine/parser/Compiler.cs |
Adds defensive assertions in static constructor to verify array and enum lengths match |
test/powershell/Language/Scripting/CommonParameters.Tests.ps1 |
Adds tests for ProgressAction parameter in both simple and complex advanced functions |
docs/community/working-group-definitions.md |
Expands "VS Code" abbreviation to full "Visual Studio Code" name |
|
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
Backport of #24591 to release/v7.4
Triggered by @TravisEz13 on behalf of @cmkb3
Original CL Label: CL-General
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Customer Impact
Fixes -ProgressAction failures in advanced functions by restoring ProgressPreference entries; prevents engine errors when the common parameter is used.
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Ran CommonParameters.Tests.ps1.
Risk
REQUIRED: Check exactly one box.
Scoped fix to common parameter handling with targeted tests.