f-miyu / Plugin.CloudFirestore

MIT License
121 stars 44 forks source link

Support ability to map property names to camelCase #22

Open simondotm opened 4 years ago

simondotm commented 4 years ago

It's typical to serialize to/from a database object that uses camelCase field names rather than the C# convention of PascalCase.

The MapTo attribute allows us override to specify a camelCase version eg.

[MapTo("phoneNumber")]
public string PhoneNumber { get; set; }, 

However, this is unnecessarily fragile, since a change of C# property name has to be updated in the attribute also.

An improvement to this would be a MapTo attribute parameter such as:

[MapTo(CamelCase=true)]
public string PhoneNumber { get; set; }, 

Or alternatively perhaps a global setting similar to the JsonSerializerSettings that allows a global preference for camelCase property mappings.

Thanks for a great library!