PowerShell / PowerShell/PowerShellEditorServices
SetValue for nested field throws "Unable to cast object"
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 767
- Forks
- 266
- Ø Merge
- 3 T. 16 Std.
- Gemergte PRs (30 T.)
- 1
Beschreibung
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 PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
- I have verified that I am using the latest version of PowerShell Editor Services.
- If this is a security issue, I have read the security issue reporting guidance.
Summary
Setting nested field value throws
Unable to cast object of type 'Microsoft.PowerShell.EditorServices.Services.DebugAdapter.VariableDetails' to type 'Microsoft.PowerShell.EditorServices.Services.DebugAdapter.VariableContainerDetails'.
The code below should be causing the problem.
PowerShell Version
Name Value
---- -----
PSVersion 7.4.3
PSEdition Core
GitCommitId 7.4.3
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Editor Version
Visual Studio Code
Version: 1.91.1 (user setup)
Commit: f1e16e1e6214d7c44d078b1f0607b2388f29d729
Date: 2024-07-09T22:06:49.809Z
Electron: 29.4.0
ElectronBuildId: 9728852
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Windows_NT x64 10.0.19045
PowerShell Editor Services Version
Major Minor Build Revision
----- ----- ----- --------
3 20 1 0
Steps to Reproduce
$val = [PSCustomObject]@{
NestedField = "Test"
}
Write-Host $val
while ($true) {
Write-Host $val
}
- Put breakpoint on line 4 (
Write-Host $val) - Start debugging
- Open "Local" scope in Variables tab
- Find $val and change NestedField value
Visuals
No response
Logs
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie mit src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs etwa bei Zeile 390 und reproduzieren Sie dann die gemeldeten Schritte mit dem verschachtelten PSCustomObject beim Debuggen. Verfolgen Sie den SetValue-Pfad, wenn Sie NestedField ändern, und überprüfen Sie, dass die Aktualisierung ohne den VariableDetails-to-VariableContainerDetails-Cast-Fehler abgeschlossen wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, powershell
- Bereich
- devtools
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 35/100