XML Serialization Reminders
Lessons from XML Serialization:
- - Tracking down errors from the exceptions & stack trace is hard.
- - Serializable classes need a public default constructor – obscure generic error message.
- - Non-polymorphic arrays can be elements to avoid nesting.
- - The XmlAnyElement allows a mix of parse & unparsed content.
- - Its easy and flexible to alter element & attribute names, shift things between elements, attributes, and text.
- - Match the value assigned to a field by the default constructor with DefaultValue attributes to keep optional stuff from appearing in the output.
- - Polymorphism works well and may be programmatically extended by using the second argument to the XmlSerializer constructor.