PowerShell / PowerShell/PowerShellEditorServices

Static methods in PSClasses are sometimes marshaled to disposed runspaces

Đang mở
#483 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Issue-Bug
Ngôn ngữ chính
C#
Star
767
Fork
266
Merge trung bình
3 ngày 16 giờ
Pull request đã merge (30 ngày)
1

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với ReproSteps.zip và logs.zip, sau đó làm theo các bước Test-Class và Get-BoundRunspace được liệt kê, đồng thời theo dõi quyền sở hữu runspace của các phương thức static trên First.ps1 và Second.ps1. Được coi là hoàn tất khi lệnh chạy thành công ở cả hai lần chạy và Get-BoundRunspace báo cáo runspace mặc định hiện tại thay vì một runspace đã bị hủy.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
shell, vscode
Lĩnh vực
devtools, tooling
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.