Skip to content

ArgumentTransform Attribute #20112

@StartAutomating

Description

@StartAutomating

Summary of the new feature / enhancement

There is a base type for a argument transformations, but there are not too many implementations of this attribute that are public.

Having a generic ArgumentTransform attribute would be highly useful for a variety of scenarios.

On practical example of this is the solution to #19704 (pr #19705).

In this scenario, we wanted to add more granularity to Wait-Event and the PowerShell committee wished to provide a TimeSpan or double value for total seconds.

Other scenarios include:

  • Converting various forms of Color to a hex value
  • Binding to a known property of a complex object
  • Extracting arguments from nested properties of objects

Proposed technical implementation details (optional)

A relatively simple ArgumentTransform attribute should exist, with two properties:

  • PropertyName (the name of the property on an input object that should serve as the value)
  • TransformScript (a [ScriptBlock] that can convert the value arbitrarily)

Metadata

Metadata

Assignees

No one assigned

    Labels

    In-PRIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions