-
Notifications
You must be signed in to change notification settings - Fork 8.2k
ArgumentTransform Attribute #20112
Copy link
Copy link
Labels
In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
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)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
In-PRIndicates that a PR is out for the issueIndicates that a PR is out for the issueIssue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugWG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime