« Timer Classes | Main | Parsing simple grammars using only a single Regex »

XML Serialization Reminders

Lessons from XML Serialization:

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

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)