{"action":"created","issue":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2864","repository_url":"https://api.github.com/repos/PowerShell/PowerShell","labels_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2864/labels{/name}","comments_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2864/comments","events_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2864/events","html_url":"https://github.com/PowerShell/PowerShell/issues/2864","id":194565144,"number":2864,"title":"Add conversion from PSMethodInfo to delegate/Func<> ","user":{"login":"powercode","id":3505151,"avatar_url":"https://avatars.githubusercontent.com/u/3505151?v=3","gravatar_id":"","url":"https://api.github.com/users/powercode","html_url":"https://github.com/powercode","followers_url":"https://api.github.com/users/powercode/followers","following_url":"https://api.github.com/users/powercode/following{/other_user}","gists_url":"https://api.github.com/users/powercode/gists{/gist_id}","starred_url":"https://api.github.com/users/powercode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/powercode/subscriptions","organizations_url":"https://api.github.com/users/powercode/orgs","repos_url":"https://api.github.com/users/powercode/repos","events_url":"https://api.github.com/users/powercode/events{/privacy}","received_events_url":"https://api.github.com/users/powercode/received_events","type":"User","site_admin":false},"labels":[{"id":401720735,"url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Area-Engine","name":"Area-Engine","color":"5319e7","default":false},{"id":311043050,"url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Issue-Enhancement","name":"Issue-Enhancement","color":"fc2929","default":false},{"id":401721267,"url":"https://api.github.com/repos/PowerShell/PowerShell/labels/Up-for-Grabs","name":"Up-for-Grabs","color":"000000","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-12-09T10:43:00Z","updated_at":"2016-12-10T15:49:17Z","closed_at":null,"body":"As a step on the way to realize #2226, I think we should start with adding a conversion from PSMethodInfo to System.Func.\r\n\r\nToday, we have to do something like this:\r\n```powershell\r\nClass MyClass {\r\n      \r\n    [int] Add47([int] $value) {    \r\n      return 47 + $value\r\n    }\r\n            \r\n    [int] DoStuff([System.Collections.Generic.IEnumerable[int]] $collection) {\r\n        # ugly\r\n        $func = $this.GetType().GetMethod(\"Add47\").CreateDelegate([Func[int,int]], $this)\r\n        return [Linq.Enumerable]::Sum($collection, $func)\r\n    }\r\n}\r\n```\r\n\r\nI would like to express that as:\r\n```powershell\r\nClass MyClass {    \r\n    [int] Add47([int] $value) {    \r\n      return 47 + $value\r\n    }\r\n            \r\n    [int] DoStuff([System.Collections.Generic.IEnumerable[int]] $collection) {\r\n        return [Linq.Enumerable]::Sum($collection, $this.Add47)\r\n    }\r\n}\r\n```\r\n\r\nWhat is the right place to do this?"},"comment":{"url":"https://api.github.com/repos/PowerShell/PowerShell/issues/comments/266217383","html_url":"https://github.com/PowerShell/PowerShell/issues/2864#issuecomment-266217383","issue_url":"https://api.github.com/repos/PowerShell/PowerShell/issues/2864","id":266217383,"user":{"login":"iSazonov","id":22290914,"avatar_url":"https://avatars.githubusercontent.com/u/22290914?v=3","gravatar_id":"","url":"https://api.github.com/users/iSazonov","html_url":"https://github.com/iSazonov","followers_url":"https://api.github.com/users/iSazonov/followers","following_url":"https://api.github.com/users/iSazonov/following{/other_user}","gists_url":"https://api.github.com/users/iSazonov/gists{/gist_id}","starred_url":"https://api.github.com/users/iSazonov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iSazonov/subscriptions","organizations_url":"https://api.github.com/users/iSazonov/orgs","repos_url":"https://api.github.com/users/iSazonov/repos","events_url":"https://api.github.com/users/iSazonov/events{/privacy}","received_events_url":"https://api.github.com/users/iSazonov/received_events","type":"User","site_admin":false},"created_at":"2016-12-10T15:49:17Z","updated_at":"2016-12-10T15:49:17Z","body":"It is a parameter binding. Try debug [here](https://github.com/PowerShell/PowerShell/blob/8abb6c3a94d304af0dd7611c865b1b2ec6460113/src/System.Management.Automation/engine/CoreAdapter.cs#L1419). If I found the right place, then most likely the cause of the problem in wrong ConversionRank.\r\n"}}
{"actor":{"display_login":"iSazonov"}}