PowerShell / PowerShell/PSScriptAnalyzer
Write-Host should be closed within the scope it was created in, unless it is a Async command type
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 2.2k
- Fork
- 414
- Merge trung bình
- 13 giờ 1 phút
- Pull request đã merge (30 ngày)
- 2
Mô tả
Summary of the new feature
Some times people don't properly close their Write-progress calls with a -Completed which can cause unexpected output, or "leftover" progress bars from commands that completed, but never closed their progress bars
Proposed technical implementation details (optional)
Write-Progress automatically stops showing open progress bars when execution is complete, but this means that if you are making an interface that does not properly close their Write-Progress progress bars with a Write-Progress -Activity $ActivityName -Completed then it stays open while other code is running, until execution stops.
It seems like in vanilla shell console, powershell can recognize that it is "done" (I'm guessing.... maybe something like the scope that created the Write-Progress is stopped? )
But if you do this in other environments, like ISE, then the Progress bars don't go away unless properly closed with a -Completed
Additionally there is the case that people who are running with something like -PercentComplete 100 but never closing.
A recommendation to close Write-Progress'es with a -Completed would effectively stop this problem
Possibly make sure each write-progress -Activity has a matching one with -Completed ? Not sure if there is a way to detect if it's closed in the same scope or if that might cause more problems
A potential problem for that would be things like People start it in the begin { } block write over time in the progress { } block, but not closing in the end { } block?
What is the latest version of PSScriptAnalyzer at the point of writing
As far as I can tell, it does nothing for this currently
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 bằng cách xác định các quy tắc analyzer và các bài kiểm thử hiện có cho các lệnh PowerShell; issue nêu Write-Progress và các lệnh gọi -Completed tương ứng nhưng không chỉ rõ tệp hoặc điểm vào nào. Làm rõ các ranh giới phạm vi và các khối begin/process/end phải hoạt động như thế nào, sau đó xác định các bài kiểm thử bao quát các loại lệnh thông thường và async trước khi triển khai.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, powershell
- Lĩnh vực
- tooling
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 20/100