-
-
Notifications
You must be signed in to change notification settings - Fork 55
Support for multiple discriminators on single type #62
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
Support for multiple discriminators on single type #62
Conversation
|
Hi, Thanks for submitting a PR to this project Could you please add some unit tests with serialization and deserialization ? Does it also work with And don't worry about the build failure related to SonarQube (it's a configuration problem) |
| _supportedTypes.Add(type.Value, type.Key); | ||
| if (_supportedTypes.ContainsKey(type.Value)) | ||
| { | ||
| if (_addDiscriminatorFirst) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_addDiscriminatorFirst or _serializeDiscriminatorProperty ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be _serializeDiscriminatorProperty
| foreach (var type in _subTypeMapping) | ||
| { | ||
| _supportedTypes.Add(type.Value, type.Key); | ||
| if (_supportedTypes.ContainsKey(type.Value)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of check is better suited in JsonSubtypesConverterBuilder (this class is internal)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConverterBuilder contains inverted dictionary, but we can add check for it anyway
|
It should work with KnownSubTypeAttribute. Attributed converter does not serialize discriminator and does not require type-to-discriminator mapping I can add tests later |
5f7bd62
into
manuc66:feature/support-for-multiple-discriminators-on-single-type
This PR allows to add multiple discriminator values for single subtype which can cover all of discriminators. This is required for compound discriminators (tuples for example) and allows to write converters like this