-
Notifications
You must be signed in to change notification settings - Fork 40
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
TypeConverter for serializing and deserializing ValueOf types #3
base: master
Are you sure you want to change the base?
Conversation
@mcintyre321 this seems to be a useful addition, and seeing you posted something similar as a fiddle https://dotnetfiddle.net/Ec7IKN, is there anything in plan to add it to the library? |
This is a really neat and useful pull request, but the reasons I couldn't decide if to merge this or not are:
If 1. could be resoved to my satisfaction (i.e. is System.ComponentModel.TypeConverter available everywhere , including Blazor, which it probably is, I wouldn't mind merging). My fiddle requires JSON.NET, so the reasons to not include the ValueTupleContractResolver and dll dependency in the main package are even stronger. |
Thanks @mcintyre321 , that explains it very well. There is unfortunately no license attached to the fiddle, could you clarify on that part? Ideally this code would be nice to have in a separate NuGet package. |
I think this feature should be added as an extension, maybe some sort of Serializer configuration and not as an annotation on class. |
I don't want to steal people away from this very useful library, but you might want to take a look Vogen as it does exactly these things. It has (opt in) conversions for Newtonsoft.Json, System.Text.Json, TypeConverter, Dapper, and EFCore It's somewhat different to this library as it enforces much stricter checking of validity, e.g. it won't let you |
Hi!
This is my second PR here in this repository.
I added a
TypeConverter
forValueOf
types. This is needed, if you want to serialize and deserialize types, e.g. withNewtonsoft.Json
. The serializer needs a hint how to serialize and deserializeValueOf
types correctly. (e.g. astring
is correctly deserialized to aClientId
).The generic
ValueOfTypeConverter
can simply be used as the following. (See the test cases for details):Note that this feature adds a dependency to
System.ComponentModel.TypeConverter
.Please let me know what you think.
Cheers!