Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add conversion from PSMethodInfo to delegate/Func<>  #2864

Copy link
Copy link
@powercode

Description

@powercode
Issue body actions

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?

Reactions are currently unavailable

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

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.