This is a simple implementation of pretty-printing for XMLSerializer. It is backwards-compatible.
Further improvements could be made, but I figured I'd start the conversation here.
Rudimentary pretty-printing, with tests. Needs documentation and robu…
So, I would imagine this more as a separate utility. It makes some sense under XMLSerializer, but the way you need to detect prettyPrint is quite annoying. What if you want to pretty print at zero indentation? I think perhaps this should be an entirely separate utility object. PrettyPrinter or something similarly descriptive.
Okay, sure. I think to avoid code duplication (of output declaration, attribute serialization etc.) I'd want to pull common code out of the XMLSerializer. I'll offer up a variant.