Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SetValue for nested field throws "Unable to cast object" #2170

Open
6 tasks done
Fantoom opened this issue Aug 1, 2024 · 2 comments
Open
6 tasks done

SetValue for nested field throws "Unable to cast object" #2170

Fantoom opened this issue Aug 1, 2024 · 2 comments
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!

Comments

@Fantoom
Copy link

Fantoom commented Aug 1, 2024

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'.

image

The code below should be causing the problem.

VariableContainerDetails variableContainer = (VariableContainerDetails)variables[variableContainerReferenceId];

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   
}
  1. Put breakpoint on line 4 (Write-Host $val)
  2. Start debugging
  3. Open "Local" scope in Variables tab
  4. Find $val and change NestedField value

Visuals

No response

Logs

No response

@Fantoom Fantoom added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Aug 1, 2024
@andyleejordan
Copy link
Member

I wonder if this is releated to PowerShell/vscode-powershell#5013 (which I think is due to an issue of the scope not updating internally).

@andyleejordan
Copy link
Member

Err I don't think it's the same but I'm adding it to my related bugs list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants