Once we have support for JsonSerializerContext, the discriminators should not cause trim or AOT warnings.
We can't currently use all of the built-in polymorphism support because it has requirements that don't match with our needs. Namely:
The discriminator must be the first attribute in the object being deserialized.
The discriminator must not be included as a property on the POCO
Multiple discriminator values can't share the same POCO type
Modifications
Use the JsonPolymorphic and JsonDerivedType attributes to ensure any generated JsonSerializerContext always includes the derived types in the metadata.
Suppress trim and AOT warnings on the generated JSON converters
Motivation
Once we have support for
JsonSerializerContext
, the discriminators should not cause trim or AOT warnings.We can't currently use all of the built-in polymorphism support because it has requirements that don't match with our needs. Namely:
Modifications
JsonPolymorphic
andJsonDerivedType
attributes to ensure any generatedJsonSerializerContext
always includes the derived types in the metadata.