Can I touch it?
A while ago I posted a method of serializing a hashtable. It pretty much comes down to converting the hashtable to an array before it's serialized.
A little after that, I talked about how this is fairly ugly in that you have to do the serialization yourself, rather than get it done automagically by using either a) the right attributes or b) hooking the serialization process. The ISerializable interface doesn't work, unfortunately.
Well I've stumbled across something pretty cool that solves my problem. But it brings extra problems with it. James Crowley posted an article on developer fusion (this link is to his blog post on the article) about hooking the xml serializer so that instead of having to explicitly perform the serialization yourself, you instead get called to provide your XML when required.
It ends up that the IXMLSerializable interface is exactly what I was looking for. If your class implements this, then when you are XML serialized, the methods you implement let you write your own XML out - and the cool thing is that you aren't limited to public properties anymore either. You can write out whatever you like. Along with this, you have to read your XML back in at deserialization time.
In the article, James mentions that this interface in the 1.1 framework is undocumented, and he hopes that in whidbey it will be there.
Well, maybe I scare easier than he does. In the 1.1 MSDN documentation, they actually say it shouldn't be used directly inside your code. In the beta version of the whidbey MSDN documentation, it's fully documented (ok, they haven't finished the examples yet, but you get the point).
This gives me a bit of a problem. I'd love to use it. Thanks to both James' article and the beta MSDN doco, I now know how to use it. I get the feeling that I'm going to have to actually return a schema if i want to pass the class across a webmethod (so the WSDL can generate properly), but that's ok.
So should I use it? On the one hand they say don't, on the other they are almost saying I can. Should i wait for the 2.0 framework to come out first? Other people have had success with it in the past - James obviously did, and this article on dotnetified shows someone (it's not clear, I think his name is Andy Hopper) who had great success with it back in May 2003. Also, Daniel Cazzulino has talked a bit about how the XMLSerializer works, which is pretty cool. See? Now that I have something to search against, I can find out a lot about it :)
But I need someone, preferably from MS, to pat me on the back and say 'It's OK, go shoot yourself in the foot'. Maybe it's time I mailed my ISV Buddy. We haven't spoken in a while. :)
Listening to: pathetic - blink 182 - (2:27)