This morning I had the simplest class, marked Serializable, and ran it through an XmlSerializer test just to "be sure". Little booger started throwing those weirdo XmlSerializer exceptions. They are so hard to understand, even if you look at the InnerException, its enough to make you go stark, raving mad.
Finally, I thought, "How about doing it backwards?" In other words, Let's write the XSD Schema and be happy with it. Then, we just fire up XSDObjectGen and let the tool generate the class, right?
Well, it serialized perfectly right out of the box. I had gotten a property assignment wrong (mistakenly assigned to the public field instead of the private one in the ctor).
There's something to be said for Contract First!
On a somewhat related side note, Oleg Tkachenko, XML MVP, has announced that XPathReader 1.1 is available. Nice Stuff, lean and mean XPath rocks!
And another: this morning I spent some time letting FXCop have fun with the assemblies in my latest Solution. It came up with a lot of stuff that "doesn't necessarily fit" (which rules can be easily turned off). However, it also came up with some very useful best - practices items concerning naming conventions, and in a couple of cases, places where the classes own disposable objects and on which I had not implemented IDisposable (so I did, and not only that - I wired up the calling classes to actually make the call!). I'd recommend FXCop if you have never used it. Best practices coding is -- well, best practices coding!
Finally, Microsoft Update replaces Windows Update with all the Office stuff all combined into one. Try it!
And, on a humorous note, Tiberias OsBurn has a cool article about "Over OOPing". I really had to laught at this one, because I myself have seen this "First Hand".