As many people will tell you I am a miserable old git at times and love a good moan. However I think it only fair to give credit where credit is due. I was updating some code today that used Microsoft’s XmlSerializer and had types decorated with DataContract attributes.
My experience of serialisers and how they give out help via error messages is that clearly the person who wrote it thinks “I am super smart and can write a serialiser from scratch. If you are too stupid to configure your types for serialisation then tough ####.” If you are lucky they will throw an error like “Error occurred.” Great thanks a bunch sometimes they just silently fail Grrrrrr!
Usual problems are no public parameter-less constructor or trying to deserialise read only properties.
Well today I got some great error messages from the XmlSerialiser telling me that I was trying to deserialise a property that had no Setter and that the type I was trying to serialise was now a Known Type. The MSDN docs for the error explained that because the type was inheriting the base class needed to be decorated with a KnownType attribute
Thanks you Microsoft