-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Closed
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime
Description
As a step on the way to realize #2226, I think we should start with adding a conversion from PSMethodInfo to System.Func.
Today, we have to do something like this:
Class MyClass {
[int] Add47([int] $value) {
return 47 + $value
}
[int] DoStuff([System.Collections.Generic.IEnumerable[int]] $collection) {
# ugly
$func = $this.GetType().GetMethod("Add47").CreateDelegate([Func[int,int]], $this)
return [Linq.Enumerable]::Sum($collection, $func)
}
}I would like to express that as:
Class MyClass {
[int] Add47([int] $value) {
return 47 + $value
}
[int] DoStuff([System.Collections.Generic.IEnumerable[int]] $collection) {
return [Linq.Enumerable]::Sum($collection, $this.Add47)
}
}What is the right place to do this?
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.The issue is fixed.WG-Enginecore PowerShell engine, interpreter, and runtimecore PowerShell engine, interpreter, and runtime