C# – Shifting between XML schemas and C# classes in a sensible fashion

cxml

A .NET/C# system receives XML messages for processing and further transmission.

Since working directly on XML documents would be very inconvenient, it is necessary to deserialize the message to a C# object and then serialize just before delivery.

Up until now this has been done with Microsoft's XSD tool (xsd.exe) and it gets the job done, but poorly. The tool is old and buggy and generates outrageous class names and code representations of the various XML schema constructs.

Are there better ways to accomplish this in .NET, or should I go a whole other way about it?

Best Answer

Unless there is an insane amount of properties, or the classes are changing on the fly, I just hand-write a POCO to handle deserialization. It is a bit of up-front investment, but if these objects are being used I like to have my naming conventions, etc., in place.