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

Implement implicit conversion between F# fun to .NET generic Func<> for ASP.NET minimal API. #1334

Open
oleksandr-bilyk opened this issue Nov 10, 2023 · 5 comments

Comments

@oleksandr-bilyk
Copy link

oleksandr-bilyk commented Nov 10, 2023

I propose F# implicitly cast F# fun with parameter attributes to C# delegate. It will help to write ASP.NET minimal API in short way

image

To do the same on F# I must create separate function.
image

C# looks better for this
image

@smoothdeveloper
Copy link
Contributor

@oleksandr-bilyk I think right now it does already do it, if you pass the lambda in the call.

Also, should this work with any delegate type instead? I'm not keen on "Func is better" stuff which is already having few edge cases in overload resolution.

@smoothdeveloper
Copy link
Contributor

Likely a special case for #1131

@brianrourkeboll
Copy link

You can write some code to work around this if you want, like I did in https://github.com/brianrourkeboll/FSharp.AspNetCore.WebAppBuilder; a few others have experimented with similar things, I believe, including @lucasteles, who opened #1131.

@gurustron
Copy link

Also note that AFAIK the attributes currently are not captured, i.e. since FromServices will be correctly inferred everything will work as expected.

@lucasteles
Copy link

@brianrourkeboll Yes, I ended up creating this https://github.com/lucasteles/FSharp.MinimalApi also

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

No branches or pull requests

5 participants