PowerShell / PowerShell/PowerShell
Improve `OrderedHashtable` integration
@SeeminglyScience đang làm issue này rồi.
Từ ngày 3/4/2023.
- 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
The new System.Management.Automation.OrderedHashtable class is a great step forward in moving to a dictionary that is ordered by default. Therefore I wouldn't be surprised that this System.Management.Automation.OrderedHashtable class would eventually replace the System.Collections.Specialized.OrderedDictionary class.
For this to happen, I would like to able to use the same syntactic sugars as with the Hashtable/Ordered type:
- Preserve the hash literal node order
Currently this doesn't work as expected (like it does for[PSCustomObject]and[Ordered]):
[System.Management.Automation.OrderedHashtable]@{ One = 1; Two = 2; Three = 3; Four = 4 }
Name Value
---- -----
Two 2
Four 4
One 1
Three 3
Side note: unlike the OrderedDictionary class, I think it is ok that the OrderedDictionary is able to cast from an unordered (non-literal) hash table (assuming that it will be documented that the order is already decayed in this matter):
$Hashtable = @{ One = 1; Two = 2; Three = 3; Four = 4 }
[System.Management.Automation.OrderedHashtable]$HashTable
- Ability to use the friendly name to cast
As with the[Ordered](and[HashTable]) type, I would like to be able to use it friendly name:
[OrderedHashtable]@{ One = 1; Two = 2; Three = 3; Four = 4 }
- ability to compare with its friendly name
As with the[Ordered]type (see: #10513), I would like to be able to use its friendly name for the-iscomparison:
$OrderedHashtable = [System.Management.Automation.OrderedHashtable]@{ One = 1; Two = 2; Three = 3; Four = 4 }
$OrderedHashtable -is [OrderedHashtable]
- Also, I would expect it somehow (pretend) to be derived from the
OrderedDictionaryclass
Currently the following returnsFalse, where I would like to see itTrueso that doesn't break scripts that test for anOrderedDictionarytype:
$OrderedHashtable = [System.Management.Automation.OrderedHashtable]@{ One = 1; Two = 2; Three = 3; Four = 4 }
$OrderedHashtable -is [Ordered]
False # Expected (wishful thinking) True
Related: #19073
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.
Đánh giá
Issue này chưa được đánh giá.