Sometimes features are staring at you in the face, all you need to do is read the docs. Other times it really feels like things are hidden. Thanks Con for pointing me to
ShouldSerializePropertyName - I did a careful look through the MSDN serialization docs in hope of finding this very feature, but didn't have any luck.
What does it do? For any given property, create a
() method to decide if it should be included in serialization. A bit magical, but does the trick.
Why do I want this? I want to serialize an object graph to XML. But I don't want to render a container element for any empty collections. I think I'm becoming a bit of a pedent when it comes to XML.
Docs (in as much as I could be find any) are over here under Windows Form Controls.