PowerShell / PowerShell/vscode-powershell
Debugging: $WhatIfPreference is always reported as $false
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 547
- PR merge metrics
- No merged PRs in 30d
Description
System Details
- Operating system name and version: Windows 10 Pro, Version 1709, Build 16299.64
- VS Code version: Code 1.18.1 (929bacba01ef658b873545e26034d1a8067445e9, 2017-11-16T18:32:36.023Z)
- PowerShell extension version: 1.5.1
- Output from
$PSVersionTable:
| Name | Value |
|---|---|
| PSVersion | 5.1.16299.64 |
| PSEdition | Desktop |
| PSCompatibleVersions | {1.0, 2.0, 3.0, 4.0...} |
| BuildVersion | 10.0.16299.64 |
| CLRVersion | 4.0.30319.42000 |
| WSManStackVersion | 3.0 |
| PSRemotingProtocolVersion | 2.3 |
| SerializationVersion | 1.1.0.1 |
Copy / paste the following commands into the PowerShell Integrated Console, and paste the output here:
PowerShell Integrated Console
PS > code -v
1.18.1
929bacba01ef658b873545e26034d1a8067445e9
PS > $pseditor.EditorServicesVersion
Major Minor Build Revision
----- ----- ----- --------
1 5 1 0
PS > code --list-extensions --show-versions
AlanWalk.markdown-toc@1.5.6
bierner.markdown-preview-github-styles@0.1.0
burtlo.inspec@0.1.2
codezombiech.gitignore@0.5.0
DavidAnson.vscode-markdownlint@0.11.1
donjayamanne.githistory@0.2.3
DotJoshJohnson.xml@1.9.2
felipecaputo.git-project-manager@1.4.0
felixfbecker.php-intellisense@2.0.1
formulahendry.code-runner@0.8.4
hangxingliu.vscode-nginx-conf-hint@0.0.4
hnw.vscode-auto-open-markdown-preview@0.0.4
jirkafajfr.vscode-kitchen@0.5.0
le0zh.vscode-regexp-preivew@0.0.3
mikestead.dotenv@1.0.0
ms-vscode.PowerShell@1.5.1
Pendrica.Chef@0.6.3
PeterJausovec.vscode-docker@0.0.22
rebornix.Ruby@0.15.0
robertohuertasm.vscode-icons@7.18.1
shanoor.vscode-nginx@0.4.1
ziyasal.vscode-open-in-github@1.3.0
PS > $PSVersionTable
Name Value
---- -----
PSVersion 5.1.16299.64
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.16299.64
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Note: I did search for similar issues, but I could not find any.
Issue Description
In a script I am writing, I have a check against $WhatIfPreference. To test this in a debugging session in VS Code, I pass the -WhatIf flag using the PowerShell Launch Current File w/Args Prompt debug option.
Test case:
[CmdletBinding(SupportsShouldProcess=$true)]
Param()
If ($WhatIfPreference) {
Write-Output "WhatIf enabled"
} Else {
Write-Output "WhatIf disabled"
}
A breakpoint has been set on the If line. Upon entering a debugging session and hitting the breakpoint, hovering the mouse over $WhatIfPreference will show $false, no matter if -WhatIf has been set. This is true for the Variables and Watch panels as well. However, the script will evaluate the variable correctly. If -WhatIf is set, the test evaluates as true.
Please let me know if there's any more information or context I should provide.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the issue in VS Code with the provided PowerShell script, breakpoint, and -WhatIf argument. Compare the value shown by hover, Variables, and Watch panels with the value used during script execution. Done means debugger views report the effective $WhatIfPreference value consistently with execution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell, typescript, vscode
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100