Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pass F# function to another F# function in C# code #6128

Closed
vasily-kirichenko opened this issue Jan 18, 2019 · 2 comments
Closed

Cannot pass F# function to another F# function in C# code #6128

vasily-kirichenko opened this issue Jan 18, 2019 · 2 comments

Comments

@vasily-kirichenko
Copy link
Contributor

image

@cartermp cartermp added this to the 16.0 milestone Jan 30, 2019
@cartermp cartermp modified the milestones: 16.0, 16.1 Feb 21, 2019
@NinoFloris
Copy link
Contributor

FuncConvert.FromFunc(x => handler(x)) should do the trick.

Handler is just a normal method in IL. When a normal method is passed into an FSharpFunc function argument within F# files the compiler will generate the accompanying function type that inherits from FSharpFunc. Just like the C# compiler does the something similar for lambda's by generating a DisplayClass. But although the F# compiler also has support for doing that same work for Func and Action, the C# compiler doesn't at all know about FSharpFunc.

Not sure if there's a more elegant way to fix this, method groups aren't really something you could implicitly convert, nor do I think that's a great idea...

@cartermp cartermp modified the milestones: 16.1, 16.2 Apr 23, 2019
@cartermp cartermp modified the milestones: 16.2, Backlog Apr 30, 2019
@dsyme
Copy link
Contributor

dsyme commented Aug 26, 2020

This is by design, or a C# language suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants