XSDClassGen for .NET 2.0

XSDClassGen for .NET 2.0

  • Comments 0

Via Dino...

If you model your data types in XSD, then maybe you have used xsd.exe, in the .NET Framework SDK.  It can generate a .NET class from an XSD, and so can be really useful in the general domain of "XML Data binding" as they call it in the Java world.  However, there are some pitfalls with xsd.exe - it does not support the full xsd spec, and the classes it generates are not very powerful.  For example, elements in the schema are just fields in the generated code, they are not full-powered properties.  This means, collections of the generated classes cannot easily be bound to databound controls in Windows Forms or ASP.NET.   

XSDObjectGen was designed to overcome some of those problems.  It is a free tool, written by Dan Rogers and provided as a free download by Microsoft.  It is not a supported part of the toolset, but it generates code that you can inspect and use in your own projects.  Pretty nice.  Advantages over XSD.exe:  It's a VS add-in.  It generates properties with getters and setters for elements in the schema, so the databinding is fixed.  Also it handles nullable value types nicely.  There's a nice article by Peter Bromberg on how to use it in interoperable contract-first web services design.  XSDObjectGen has been updated regularly, the current release is v1.4.4.1.

Now comes XSDClassGen, which is sort of like XSDObjectGen++.  This one is from Ram Marappan, supports .NET 2.0 including generation of generic types for collections, nullable types for value types, and so on.  Worth checking out.

I've used both XSD.exe & XSDObjectGen before.  These tools are very handy for scenarios where you will be building applications on .NET that need to interoperate with applications on other platforms.  Be sure to check out the new XSDClassGen tool too!