PowerShell / PowerShell/PowerShell

`ValueFromPipelineDictionaryName` and `ValueFromPipelineDictionaryValue` parameter attributes

Open
#20,489 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue-Enhancement Needs-Triage
Dominant language
C#
Stars
55.5k
Forks
8.5k
Avg merge
1d 2h
Merged PRs (30d)
88

Description

Summary of the new feature / enhancement

Adding a ValueFromPipelineDictionaryName and a ValueFromPipelineDictionaryValue parameter attribute could help towards a
common approach to enumerate dictionaries for processing at run-time. This prevents a new iDictionary parameter and required parameterset exclusions

Proposed technical implementation details (optional)

Wishful thinking (for cmdlets along with Set-Item):

param(
    [Parameter(ValueFromPipelineDictionaryName=$true, ParameterSetName='Path', Mandatory=$true, Position=0, ValueFromPipelineByPropertyName=$true)]
    [string[]]
    ${Path},

    [Parameter(ValueFromPipelineDictionaryValue=$true, Position=1, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
    [System.Object]
    ${Value},

    ...
Pipeline

In case of a Pipeline input, it will divide the name and value of each dictionary item to respectively the Path or Value parameters.

Example: (Wishful thinking)

Set-Location -Path "ENV:\"
$HashTable = @{ DEMO_CLIENT_ID = "ff3b7b84-e041-4e76-993e-239930808aa7"; MyPath = "C:\MyPath" }
$HashTable | Set-Content
Argument

If supplied as an argument for either Name - or Value parameter it will bind both parameters to the respective parameters that contain the ValueFromDictionaryName and ValueFromDictionaryValue parameters.

Example: (Wishful thinking)

Set-Location -Path "ALIAS:\"
Set-Item -Path @{ np = "c:\windows\notepad.exe" }

Consequently, an error is expected when either of the parameter is assigned twice, e.g.: (in the above Set-Item example:

Set-Item -Path @{ np = "c:\windows\notepad.exe" } -Value 'Word.exe' # Should error
</strike>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no files, tests, or entry points. Start by locating PowerShell's parameter-binding and dictionary pipeline handling, then define the intended behavior for the two attributes and verify it with tests covering dictionary names, values, pipeline input, and conflicting bindings.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.