PowerShell / PowerShell/PowerShell

$PSBoundParametersDictionary should better inherit from System.Collections.Hashtable

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

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

Issue-Enhancement Needs-Triage
Ngôn ngữ chính
C#
Star
55.5k
Fork
8.5k
Merge trung bình
1 ngày 2 giờ
Pull request đã merge (30 ngày)
88

Mô tả

Summary of the new feature / enhancement

Currently the System.Management.Automation.PSBoundParametersDictionary class inherits from System.Collections.Generic.Dictionary<string, object>. This leads to following problems:

Whenever you add or remove elements to or from the automatic variable PSBoundParameters, a bool value is output. This is because the Add and Remove methods of the class Dictionary are not void.

That is for C# not a problem, but in Powershell, a script or function using those methods produces unwanted output.

I propose to inherit from the System.Collections.Hashtable class. This is actually also what a pwsh developer would expect.

I also recommend to define a specialized object for the Value object of each parameter element. This specialized object, let's call it PSBoundArgument should have two read-only properties:

IsBoundPositionally
IsBoundByDefaultValue

This approach is much more reasonable than the current solution of having a List of positional values as the BoundPositionally property of the dictionary!

That, of course, would complicate the assignment of new items to $PSBoundParameters, so the Add method has then to be overridden, so that objects of correct types are added to the hashtable. Maybe a third property called IsAdditional is then reqired too.

Proposed technical implementation details (optional)

No response

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

Không có tệp hoặc bài kiểm thử nào được nêu. Hãy bắt đầu bằng cách tìm lớp System.Management.Automation.PSBoundParametersDictionary và xem xét tính kế thừa hiện tại, hành vi Add/Remove cũng như cách biểu diễn BoundPositionally; để hoàn tất, cần xác định và triển khai các thay đổi API được đề xuất cùng với phạm vi kiểm thử hồi quy phù hợp.

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
cli
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

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.