PowerShell / PowerShell/vscode-powershell

Conditional Breakpoint: Does Not Stop When Using A Private Variable

Ouverte
#5,301 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Issue-Bug Needs: Triage
Langage dominant
TypeScript
Étoiles
1.9k
Forks
548
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

Prerequisites
  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.
Summary

When the condition in a conditional breakpoint contains a reference to a private variable defined by the script, the breakpoint is not activated.

PowerShell Version
Name                           Value
----                           -----
PSVersion                      7.4.12
PSEdition                      Core
GitCommitId                    7.4.12
OS                             Microsoft Windows 10.0.20348
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0.}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
Visual Studio Code Version
1.105.1
x64
Extension Version
ms-vscode.powershell@2025.4.0
Steps to Reproduce
  1. Launch VS Code with the PowerShell extension installed.
  2. Paste the following code into a new window.
$numbers = 1..100

foreach ($private:number in $numbers) {
    write-host $private:number
    if ($private:number -eq 100) {
        write-warning "The breakpoint should trip before this line of code."
    }
}
  1. Add a breakpoint to line 4.

  2. Right-click on the breakpoint and click on "Edit Breakpoint..."

  3. Enter the following expression.
    $private:number -eq 100

  4. Run the script.

Visuals

No response

Logs

After setting the log level to Trace, I restarted VS Code and reproduced the issue. Afterwards, none of the folders in "%APPDATA%\Code\User\globalStorage\ms-vscode.powershell\logs" appeared to have been modified today.

This issue might be related to https://github.com/PowerShell/vscode-powershell/issues/5223. But that one uses "$_" instead of "$private:".

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Exécutez le script PowerShell signalé dans VS Code avec un point d’arrêt conditionnel à la ligne 4 utilisant $private:number -eq 100, et comparez-le à l’arrêt attendu avant l’avertissement. Examinez l’issue associée #5223 et suivez la gestion des conditions des points d’arrêt par l’extension. La tâche est terminée lorsque le point d’arrêt s’active quand la variable privée atteint 100.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
powershell, vscode
Domaine
developer-experience, tooling
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
38/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.