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

Add support for ASP.NET Core #2

Open
MangelMaxime opened this issue Nov 8, 2019 · 10 comments
Open

Add support for ASP.NET Core #2

MangelMaxime opened this issue Nov 8, 2019 · 10 comments

Comments

@MangelMaxime
Copy link
Contributor

From Thoth created by nirvinm: MangelMaxime/Thoth#176

In ASP.NET Core 3, Newtonsoft.Json can replace default serializer by installing Microsoft.AspNetCore.Mvc.NewtonsoftJson package and configuring it with AddNewtonsoftJson() method in Startup.fs or Startup.cs

If Thoth can provide similar interface to replace ASP.NET serializer, it'll take away a lot of pain in configuring Thoth JSON in F# web applications written with ASP.NET Core.

@MangelMaxime
Copy link
Contributor Author

@MangelMaxime

Have a look at this.

Looks like we need to implement IActionResultExecutor<JsonResult> that'll convert the result to Json and write it to the Response stream.

Yes it would be great if you can create a new package like Thoth.Json.AspNetCore which will replace the stock serializer with Thoth. I can help you implementing it.

@MangelMaxime
Copy link
Contributor Author

@MangelMaxime I meant the stock ASP.NET Core with MVC not Giraffe.

@MangelMaxime
Copy link
Contributor Author

@nirvinm Ok, sorry I am not using .Net daily and so learning a bit of it when people ask for new features :)

I am ok with experimenting for adding support of stock ASP.NET Core.

Do you know how to hooks a custom JsonConverter to ASP.NET Core? Or do you know any documentation about it?

If you want to give it a try I can create a new repo (to host the new library) so you can send a PR to it and work from here together?

@MangelMaxime
Copy link
Contributor Author

Ok, thank you for the info.

I will create the repo tomorrow and ping you when it's available :)

@MangelMaxime
Copy link
Contributor Author

Are you using ASP.NET Core directly or via Giraffe?

Because we already provide this kind of support for Giraffe:

https://thoth-org.github.io/Thoth.Json/#Giraffe

@MangelMaxime
Copy link
Contributor Author

Hello @nirvinm The repo is available here

@MangelMaxime
Copy link
Contributor Author

@MangelMaxime Thanks for creating the repo. I'm not an expert either in this area, so give me a couple of days so I can try implementing it.

@nirvinm
Copy link

nirvinm commented Nov 9, 2019

@MangelMaxime Hey I was trying to implement the interface and I'm currently blocked because Thoth.Auto.generateEncoder() or Thoth.Auto.toString() doesn't serialize Object types. Unlike Giraffee's interface, ASP.NET's IActionResultExecutor<JsonResult> doesn't preserve type information. I have a Value of type Object. In this case how do I make Thoth to work?

@MangelMaxime Is there a way to ping you like IRC or Matrix?

@MangelMaxime
Copy link
Contributor Author

@nirvinm Hello, I think we had a similar problem with Converter API and I added LowLevel API for this case.

Source code

One person reported an issue about the converter not working in every case but I didn't check yet if it was a limitation or a bug.

In general, I am available on Fable Gitter or FSF slack.

@nirvinm
Copy link

nirvinm commented Nov 13, 2019

@MangelMaxime That worked perfectly. Thanks. Give me a couple of days. I'll implement and give a PR.

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

2 participants