PowerShell / PowerShell/PowerShellEditorServices

Static methods in PSClasses are sometimes marshaled to disposed runspaces

未关闭
#483 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

Issue-Bug
主要语言
C#
星标
767
派生
266
平均合并
3 天 16 小时
30 天内合并 PR
1

描述

logs.zip
ReproSteps.zip

Steps to reproduce

  1. Download an extract in the included example.

  2. Move the folder "Example" into your PSModulePath

  3. Open the folder "Example2" in VSCode

  4. Open the file "First.ps1" and run the command Test-Class (this is a function from "Example")

  5. (Optional) Run the command included in "First.ps1", this will show the runspace the static method is currently bound to.

  6. Open the file "Second.ps1" and run the command Test-Class again.

  7. (Optional) Run Get-BoundRunspace again.

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.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 ReproSteps.zip 和 logs.zip 开始,然后按照列出的 Test-Class 和 Get-BoundRunspace 步骤进行,同时跟踪 First.ps1 和 Second.ps1 中静态方法的 runspace 所有权。命令在两次运行中都成功,并且 Get-BoundRunspace 报告当前默认 runspace 而不是已释放的 runspace,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
shell, vscode
领域
devtools, tooling
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。