TypeConverter for serializing and deserializing ValueOf types#3
TypeConverter for serializing and deserializing ValueOf types#3meinsiedler wants to merge 2 commits intomcintyre321:masterfrom
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
TypeConverterforValueOftypes. This is needed, if you want to serialize and deserialize types, e.g. withNewtonsoft.Json. The serializer needs a hint how to serialize and deserializeValueOftypes correctly. (e.g. astringis correctly deserialized to aClientId).The generic
ValueOfTypeConvertercan 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!