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#-friendly api #318

Merged
merged 3 commits into from
Aug 22, 2023
Merged

C#-friendly api #318

merged 3 commits into from
Aug 22, 2023

Conversation

Tarmil
Copy link
Member

@Tarmil Tarmil commented Aug 19, 2023

Fixes #313. (cc @xperiandri)

Use OptionalAttribute, Func and Action instead of F#-style optional parameters and functions to provide a more C#-friendly API.

This should be a source-compatible change for most users; however, it will break explicit uses of ?paramName = optionValue, and possibly some type inference scenarios for function arguments.

* Use C#-style OptionalAttribute instead of F#-style optional arguments
* Use Func and Action instead of F# functions
* Use C#-style OptionalAttribute instead of F#-style optional arguments
* Use Func instead of F# function
Copy link
Contributor

@xperiandri xperiandri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

this.MapFallback(fun ctx ->
let page = page ctx
let page = page.Invoke(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let page = page.Invoke(ctx)
let page = page.Invoke ctx

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestions! I actually tend to prefer parenthesized syntax for methods though, even if they're single-argument.

| None -> serOptions.Converters.Add(JsonFSharpConverter())
| Some f -> f serOptions }
| null -> serOptions.Converters.Add(JsonFSharpConverter())
| f -> f.Invoke(serOptions) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| f -> f.Invoke(serOptions) }
| f -> f.Invoke serOptions }

@Tarmil Tarmil merged commit 02e81fd into master Aug 22, 2023
7 checks passed
@Tarmil Tarmil deleted the csharp-friendly-api branch August 22, 2023 12:56
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

Successfully merging this pull request may close these issues.

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