PowerShell / PowerShell/PowerShell
$PSBoundParametersDictionary should better inherit from System.Collections.Hashtable
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 55.5k
- Forks
- 8.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 88
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named. Start by locating the System.Management.Automation.PSBoundParametersDictionary class and reviewing its current inheritance, Add/Remove behavior, and BoundPositionally representation; done would require settling and implementing the proposed API changes with suitable regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100