PowerShell / PowerShell/PowerShell
$PSBoundParametersDictionary should better inherit from System.Collections.Hashtable
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 55.5k
- Forks
- 8.5k
- Ø Merge
- 1 T. 2 Std.
- Gemergte PRs (30 T.)
- 88
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Es wurde keine Datei und kein Test genannt. Beginnen Sie damit, die Klasse System.Management.Automation.PSBoundParametersDictionary zu finden und ihre aktuelle Vererbung, ihr Add/Remove-Verhalten sowie die Darstellung von BoundPositionally zu überprüfen; dafür müssten die vorgeschlagenen API-Änderungen geklärt und implementiert und eine geeignete Regressionstestabdeckung erstellt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp, powershell
- Bereich
- cli
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 20/100