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

Change property resolution of To<TModel>() to align with Newtonsoft.Json convention #52

Open
wingertge opened this issue Sep 7, 2017 · 6 comments

Comments

@wingertge
Copy link

This is a feature request. JSON convention says field names should start lowercase, while C# Properties start with an uppercase letter. Newtonsoft.Json converts the casing when serializing/deserializing, the FaunaDB driver should do so as well. Right now I either have to lowercase my model properties, or uppercase JSON fields, due to the lack of conversion (neither of which is a satisfactory solution).

@marrony
Copy link
Contributor

marrony commented Sep 8, 2017

Hi @wingertge, using the attribute FaunaField to rename the field didn't solve your problem or this is not a possibility?

@wingertge
Copy link
Author

I didn't see that anywhere in the documentation so I didn't know about it. In general I find the documentation rather lacking, a simple list of functions with their signatures doesn't help all that much. Anyways, that would solve the issue. I still think it's odd that the To method doesn't do this by default though - especially since the driver already uses Newtonsoft.Json as a dependency.

@marrony
Copy link
Contributor

marrony commented Sep 11, 2017

What documentation you're referring? We should take that into consideration to improve our docs for other users

@wingertge
Copy link
Author

I'm talking about the docs available on the website. It doesn't really cover many of the common usecases. For example, deleting or updating a record based on a single index match is a pretty common usecase, but the only mention of delete/update is using a ref. I managed to somewhat figure it out with the Roslyn REPL and a local DB instance, but that kind of thing should be on the docs.

That's really the main issue I meant. It could use more documentation on common real life use cases.

@eaceaser
Copy link
Contributor

Thanks for the feedback! I'll file a ticket internally to make the serialization/deserialization behavior match Newtonsoft.Json conventions a bit closer. I'll leave this ticket open to keep you updated on the progress.

As far as the docs go:

  • Right now, you're absolutely right. There's a gap between the pure reference documentation and our tutorials, which are a bit higher level. We're working on improving the docs, but in the meantime, if you haven't already, drop into our Gitter chat (https://gitter.im/fauna/Lobby) with questions.

  • We should be publishing csharp specific API documentation. I'll file a ticket to make sure we publish these.

@goncalo-oliveira
Copy link
Contributor

The casing really is annoying. The driver expects the property name to match exactly the field name and in .NET, properties usually start with an uppercase. The workaround is simple, to use the FaunaField attribute with the proper casing... But this equally annoying and adds unnecessary clutter to the model.
I think that the matching should be case-insensitive, like Newtonsoft.Json converter does by default (or System.Text.Json).

It also annoys me that I can't deserialize into a generic Dictionary<string, object - or haven't figured out how, yet.

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

4 participants