PowerShell / PowerShell/vscode-powershell

Debugging: $WhatIfPreference is always reported as $false

Aperta
#1,109 2 commenti 2 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Area-Debugging Issue-Bug
Lingua principale
TypeScript
Stelle
1.9k
Fork
548
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il problema in VS Code con lo script PowerShell fornito, il breakpoint e l'argomento -WhatIf. Confronta il valore mostrato dai pannelli Hover, Variables e Watch con il valore utilizzato durante l'esecuzione dello script. Il lavoro è completato quando le viste del debugger riportano il valore effettivo di $WhatIfPreference in modo coerente con l'esecuzione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
powershell, typescript, vscode
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.