Model generation in DPG Grow-Up will require serialization / deserialization code generated in a variety of places. We can try to use existing serialization / deserialization writers, but those would require some improvements.
Current state:
SerializationWriter contains entry point for serialization/deserialization writing for SchemaObjectType. It writes method signatures and deserialization logic for discriminators
RequestWriterHelpers writes some parts of the serialization inline in the CreateXxxRequest method
JsonPropertySerialization and JsonAdditionalPropertiesSerialization references ObjectTypeProperty, which makes JSON serialization bound to ObjectType, no random object can be serialized. Same problem with XmlObjectAttributeSerialization.
Methods in JsonCodeWriterExtensions and XmlCodeWriterExtensions use chain of callbacks (XmlCodeWriterExtensions,ToDeserializeCall - callback of callback, Action<CodeWriter, CodeWriterDelegate>), which makes it very hard to debug or modify this code.
Some variables are created without CodeWriterDeclaration which can result in name conflict
Expected result:
Make object graph that represents data for JSON and XML serialization self-contained, so it can be created from any set of objects or constructed from scratch for testing purposes
Move all graph construction logic from writer into builder (e.g. CollectProperties is not writer logic)
Get rid of callbacks where possible (ideally - get rid of all callbacks).
Model generation in DPG Grow-Up will require serialization / deserialization code generated in a variety of places. We can try to use existing serialization / deserialization writers, but those would require some improvements.
Current state:
SchemaObjectType
. It writes method signatures and deserialization logic for discriminatorsCreateXxxRequest
methodExisting problems:
JsonPropertySerialization
andJsonAdditionalPropertiesSerialization
referencesObjectTypeProperty
, which makes JSON serialization bound toObjectType
, no random object can be serialized. Same problem withXmlObjectAttributeSerialization
.JsonCodeWriterExtensions
andXmlCodeWriterExtensions
use chain of callbacks (XmlCodeWriterExtensions,ToDeserializeCall
- callback of callback,Action<CodeWriter, CodeWriterDelegate>
), which makes it very hard to debug or modify this code.CodeWriterDeclaration
which can result in name conflictExpected result: