PowerShell / PowerShell/PowerShellEditorServices
Static methods in PSClasses are sometimes marshaled to disposed runspaces
Chưa có ai nhận issue này.
- 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ả
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.
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- 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