-
Notifications
You must be signed in to change notification settings - Fork 517
Description
Prerequisites
- I have written a descriptive issue title.
- I have searched all 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.
Summary
I have trouble debugging the following script. (Of course, this is the bare minimum of the code required to reproduce the bug I'm reporting. My actual scripts are more complex. They often have SupportsShouldProcess
and the corresponding code.)
[Cmdletbinding()]
param ()
function MyAwesomeFunction1 {
[Cmdletbinding()]
param ()
# Code here
}
function MyAwesomeFunction2 {
[Cmdletbinding()]
param ()
# Code here
}
MyAwesomeFunction1 @args
MyAwesomeFunction2 @args
PowerShell 5.1 and 7.2.1 run it just fine. But PowerShell Extension for Visual Studio generates the following:
PS C:\> c:\PublicStaticVoidMain.ps1
MyAwesomeFunction1: C:\PublicStaticVoidMain.ps1:18:1
Line |
18 | MyAwesomeFunction1 @args
| ~~~~~~~~~~~~~~~~~~~~~~~~
| A positional parameter cannot be found that accepts argument '$null'.
MyAwesomeFunction2: C:\PublicStaticVoidMain.ps1:19:1
Line |
19 | MyAwesomeFunction2 @args
| ~~~~~~~~~~~~~~~~~~~~~~~~
| A positional parameter cannot be found that accepts argument '$null'.
PowerShell Version
Name Value
---- -----
PSVersion 7.2.1
PSEdition Core
GitCommitId 7.2.1
OS Microsoft Windows 10.0.19044
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.64.2
f80445acd5a3dadef24aa209168452a3d97cc326
x64
Extension Version
ms-vscode.powershell@2021.12.0
Steps to Reproduce
On a test machine with a fresh copy of Windows, a copy of Visual Studio Code 1.64.2 x64, and PowerShell Extension version 2021.12.0, do the following:
- Create a new file. (Press Ctrl+N.)
- Set its language to PowerShell. (Press Ctrl+K, M. From the drop-down list, select "PowerShell.")
- Wait for the PowerShell console to start.
- Copy and paste the code snippet I provided above. (19 lines.)
- Save the file as
C:\PublicStaticVoidMain.ps1
. You may use other names and address if you are familiar with the peculiarities of PowerShell. For example, please don't use the single quotation mark (') the U+2018 character in the file name! - Issue a
Debug: Start Debugging
command. (Press F5.)
Expected result: The script should "run" (so to speak) and return nothing.
Actual result: The script returns two errors. (See the "Summary" section above.)
Workaround: In step 6, instead of issuing a Debug: Start Debugging
command, access the console and type: & C:\PublicStaticVoidMain.ps1
. All of your breakpoints still work, and Visual Studio Code shows watched variables.
Visuals
Logs
I set the log level to Diagnostics
and now VSCode isn't responding! 😤 However, this issue is reproducible on any computer. Hence, if the logs are essential, anybody can obtain their logs from their machines.