PowerShell / PowerShell/PowerShellEditorServices
Static methods in PSClasses are sometimes marshaled to disposed runspaces
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 767
- フォーク
- 266
- 平均マージ
- 3日 16時間
- マージ済み PR(30日)
- 1
説明
Steps to reproduce
-
Download an extract in the included example.
-
Move the folder "Example" into your PSModulePath
-
Open the folder "Example2" in VSCode
-
Open the file "First.ps1" and run the command
Test-Class(this is a function from "Example") -
(Optional) Run the command included in "First.ps1", this will show the runspace the static method is currently bound to.
-
Open the file "Second.ps1" and run the command
Test-Classagain. -
(Optional) Run
Get-BoundRunspaceagain.
Expected results
The command Test-Class to output Test was successful both times, and Get-BoundRunspace to return the current default runspace both times.
Actual results
The command Test-Class works the first time, but after the second file is opened it throws a null reference exception and Get-BoundRunspace shows a runspace that is no longer open.
Notes
The steps are exact, if Test-Class isn't ran before switching files, or if "Second.ps1" is loaded first, it won't happen.
Although the steps may seem strange, this happens to me frequently if my module is in the module path, and makes static methods in classes not viable. My assumption is that PSES creates a runspace for PSSA which then loads the module causing that execution context to be the new owner. The runspace is then disposed, but the owner doesn't revert.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
ReproSteps.zip と logs.zip から開始し、First.ps1 と Second.ps1 にまたがって static-method の runspace 所有権を追跡しながら、記載されている Test-Class と Get-BoundRunspace の手順に従います。コマンドが両方の実行で成功し、Get-BoundRunspace が破棄された runspace ではなく現在の default runspace を報告すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- shell, vscode
- 領域
- devtools, tooling
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100