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

[C# interop] Adding Bolero to ASP.NET Core project in C# is not friendly #313

Closed
xperiandri opened this issue Jul 4, 2023 · 4 comments · Fixed by #318
Closed

[C# interop] Adding Bolero to ASP.NET Core project in C# is not friendly #313

xperiandri opened this issue Jul 4, 2023 · 4 comments · Fixed by #318
Labels
enhancement New feature or request

Comments

@xperiandri
Copy link
Contributor

xperiandri commented Jul 4, 2023

It is better to switch to .NET-compatible optional parameters for this public API.
I mean all related to building the host, services, endpoints etc.

@granicz
Copy link
Member

granicz commented Jul 5, 2023

Can you paste here your proposal? Thanks!

@Tarmil Tarmil added the enhancement New feature or request label Aug 16, 2023
@Tarmil
Copy link
Member

Tarmil commented Aug 16, 2023

This seems reasonable. I think also that taking Func and Action arguments instead of F# functions would be similarly helpful. You can still pass an F# lambda and it will be implicitly converted to these types.

As far as I can tell, these methods would need to be converted:

  • IServiceCollection.AddBoleroHost
  • IServiceCollection.AddBoleroRemoting (and its many overloads, both client-side and server-side)
  • IEndpointRouteBuilder.MapFallbackToBolero

@xperiandri Do you have any others in mind?

@xperiandri
Copy link
Contributor Author

Also, question mark parameters.
We can rewrite as

static member AddBoleroHost(this: IServiceCollection, [<OptionalParameter>] server: bool voption, [<OptionalParameter>] prerendered: bool voption, [<OptionalParameter>] devToggle: bool voption) =

Then you can either omit the parameter or pass ValueOption.ValueSome with a value.
The default value will become ValueOption.ValueNone as it is a struct.

Same thing will work with Option as well, but accept null too

@Tarmil
Copy link
Member

Tarmil commented Aug 17, 2023

I think we can even go for the simpler [<Optional>] server: bool, with an additional [<DefaultParameterValue true>] for the ones that are true by default.

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

Successfully merging a pull request may close this issue.

3 participants