PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.7k stars 488 forks source link

[Preview-2020.2.0] Breakpoint - Hit Count not working with Set-StrictMode #2486

Open mrboring opened 4 years ago

mrboring commented 4 years ago

System Details

System Details Output

### VSCode version: 1.42.1 c47d83b293181d9be64f27ff093689e8e7aed054 x64

### VSCode extensions:
ms-vscode.powershell-preview@2020.2.0

### PSES version: 2.0.0.0

### PowerShell version:

Name                           Value     
----                           -----     
PSVersion                      7.0.0-rc.2
PSEdition                      Core
GitCommitId                    7.0.0-rc.2
OS                             Microsoft Windows 10.0.18362
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Issue Description

Breakpoints based on Hit Count don't work when Set-StrictMode is set.

Expected Behaviour

I expected the Breakpoint to be hit.

Actual Behaviour

Breakpoint was not hit.

Here are my steps to reproduce the issue:

  1. Started Windows Sandbox
  2. Installed PowerShell: PowerShell-7.0.0-rc.2-win-x64.msi
  3. Installed Pester: Install-Module pester -Scope CurrentUser
  4. Installed VS Code: VSCodeUserSetup-x64-1.42.1.msi
  5. Add the following to settings.json:
{
    "powershell.developer.featureFlags": [
        "PSReadLine"
    ],
    "editor.fontSize": 11,
    "terminal.integrated.fontSize": 11,
    "extensions.ignoreRecommendations": true,
    "extensions.autoCheckUpdates": false,
    "extensions.autoUpdate": false,
    "powershell.developer.editorServicesLogLevel": "Diagnostic",
    "powershell editor services.trace.server":"verbose"
}
  1. Installed PowerShell extension: PowerShell-Preview-2020.2.0.vsix
  2. Closed VS Code
  3. Unzipped test project (Issue.zip) to a folder on the desktop
  4. Right clicked on folder and selected Open with Code
  5. Set a Breakpoint on line 4 of HitCountNotWorking.psm1
  6. Edit Breakpoint: Hit Count = 1
  7. Opened Test-HitCountNotWorking.Tests.ps1
  8. Clicked Debug tests
  9. Breakpoint was not hit
  10. Opened HitCountNotWorking.psm1
  11. Commented out line 1: # Set-StrictMode -Version Latest
  12. Opened Test-HitCountNotWorking.Tests.ps1
  13. Clicked Debug tests
  14. Breakpoint was hit

Attached Logs

PowerShell Editor Services Logs.txt PowerShell Extension Logs.txt

SydneyhSmith commented 4 years ago

The hit count relies on script that is not strict mode compliant, which is likely why you are hitting this issue. Because of this I will mark this as an enhancement, although we may investigate alternatives to this script. Thanks!

rjmholt commented 4 years ago

Code for reference