PowerShell / PowerShell/PowerShellEditorServices

SetValue for nested field throws "Unable to cast object"

オープン
#2,170 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

Issue-Bug Needs: Triage
主要言語
C#
スター
767
フォーク
266
平均マージ
3日 16時間
マージ済み PR(30日)
1

説明

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.

https://github.com/PowerShell/PowerShellEditorServices/blob/41fce39f491d5d351b4ac5864e89857ec070e107/src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs#L390

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず src/PowerShellEditorServices/Services/DebugAdapter/DebugService.cs の390行目付近から始め、デバッグ中にネストされた PSCustomObject を使って報告された手順を再現します。NestedField を変更する際の SetValue パスを追跡し、VariableDetails-to-VariableContainerDetails キャストエラーが発生せずに更新が完了することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, powershell
領域
devtools
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。