Implement OneOfStructJsonConverter that serializes OneOf structures with value and reference arguments.#4
Implement OneOfStructJsonConverter that serializes OneOf structures with value and reference arguments.#4r-arjocu wants to merge 1 commit intodpraimeyuu:masterfrom
Conversation
…nd tests, that cover the serialization of OneOf structures with value and reference arguments.
|
@ra-mt Sorry for a long time without any answer from my side. I am totally fine with having a second converter, as long as it gets properly documented by telling the differences and mainly why it exists. I don't have any "roadmap" so if it helps to solve your problem - I am totally for adding it. |
|
Unfortunately, I'm changed jobs right now and have other bigger hurdles. I don't expect to be able to contribute for some time; as I see it, I may forget about this. So, my idea is following: you merge what I have provided in this pull request, and from my point of view you can change the code layout (introduce namespaces, static classes etc.) as you deem feet (I won't mind). What do yo say? I would name it |
|
Hi. I will change my username to r-arjocu. I'm unsure how this will effect the pull req. |

OneOfStructJsonConvertersources with T0-T2 generic arguments and tests for them are provided. Unfortunately I don't know how to write code that generates code (and don't have the time to learn now), but additional implementations with T3 through T8 generic arguments can be easily implemented by copy-paste with minor adjustments and appropriate tests.The implementation doesn't cover all value types according to Newtonsoft's
JTokenType, but these can be relatively easily added with the appropriate tests.The reasoning behind a second JSON converter in the repo is that I could not make
OneOfJsonConverterwork correctly directly withOneOf<>structure, because of the latter's restrictions enforced by its design -- I'm certain you're quite aware of them. So I needed a different name for the converter, because of the variant with only T0 generic argument that clashes withOneOfJsonConverter. Do you think thatOneOfStructJsonConverteris a good name?