PowerShell / PowerShell/vscode-powershell
PowerShell Integrated Console: "Value cannot be null" for missing mandatory parameter when debugging
Nessuno ha ancora preso questa issue.
- Lingua principale
- TypeScript
- Stelle
- 1.9k
- Fork
- 548
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Issue Type: Bug
Steps to reproduce
Create a .ps1 script file with the following contents:
class MyNewClass {
[string] $DummyVar
}
function Get-Details {
param (
[Parameter(Mandatory)][MyNewClass] $ClassVar,
[Parameter(Mandatory)][String] $StringVar
)
$ClassVar | Out-Host
}
Get-Details
Run the script from a PowerShell terminal window in VSCode.
Expected behavior
Using an explicit "pwsh" terminal inside VSCode, or an external Windows PowerShell or PowerShell Core shell, the above code gives:
cmdlet Get-Details at command pipeline position 1
Supply values for the following parameters:
ClassVar:
Actual behavior
From the PowerShell Integrated Console, the same script results in:
Value cannot be null.
Parameter name: type
At C:\Users\myuser\Documents\Development\PowerShell\TestParamNull.ps1:14 char:1
+ Get-Details
+ ~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], ArgumentNullException
+ FullyQualifiedErrorId : System.ArgumentNullException
If I explicitly call "pwsh" from inside this same integrated console, the script then works as expected.
Best guesses are that the issue is occurring when the debugger is involved, or that your readline is choking because it doesn't know how to request the user enters a custom class?
Environment data
Explicit pwsh
PS> $PSVersionTable
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS> $PSHOME
C:\Program Files\PowerShell\6
PowerShell Integrated Console
PS>$PSVersionTable
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
PS> $PSHOME
C:\Program Files\PowerShell\6
VSCode PowerShell Debugger Launch Config
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [],
"cwd": "${file}"
}
Extension version: 1.12.1
VS Code version: Code 1.34.0 (a622c65b2c713c890fcf4fbf07cf34049d5fe758, 2019-05-15T21:59:37.030Z)
OS version: Windows_NT x64 10.0.17763
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz (8 x 2904) |
| GPU Status | 2d_canvas: enabled checker_imaging: disabled_off flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: disabled_software rasterization: enabled surface_synchronization: enabled_on video_decode: enabled webgl: enabled webgl2: enabled |
| Load (avg) | undefined |
| Memory (System) | 31.81GB (14.95GB free) |
| Process Argv | |
| Screen Reader | no |
| VM | 0% |
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Riproducete lo script MyNewClass/Get-Details fornito dalla PowerShell Integrated Console e confrontatelo con un terminale pwsh esplicito. Iniziate tracciando il percorso di richiesta dei parametri del debugger e della Integrated Console usando la PowerShell Debugger Launch Config fornita. Il lavoro è completato quando la Integrated Console richiede il parametro obbligatorio mancante invece di segnalare un errore di tipo null.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- powershell, vscode
- Ambito
- cli, 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