XmlGen# vs. Xsd2Code

Apr 30, 2009 at 3:52 AM
Hi Everyone,
I thought I'd point out that I also started on a project with similar goals to Xsd2Code.  It's available at http://www.codeplex.com/xmlgensharp.

At this point, you might legitimately ask why I wrote XmlGen# if Xsd2Code was already available?  For starters, at the time I started XmlGen#, I think Xsd2Code wasn't quite as far along as it is right now, or at least, I didn't think it was.  Secondly, it was a learning project for me to dive into .NET XML more thoroughly.  Third, I've never really figured out how to fully utilize XmlSerializer, and I wanted something that didn't use it.  I found myself on a lot of projects writing code that drilled down into the XML structure in a recursive manner, and I got tired of writing that kind of code, so I thought, why not just write a code generator to do it.  Fourth, I wanted something that would give me "better" error handling support (or at least, error handling support I can understand).  I'm still working on the error handling.  That's not quite done yet.  So there were a lot of reasons.

The main difference between the two projects I would say is that XmlGen# generates it's own code, whereas Xsd2Code relies on the built-in .NET class XmlCodeExporter, which is the same class that xsd.exe uses.  You can customize the code generated by XmlCodeExporter, but I think it takes more effort to figure out what is going on.  I think the code generated by XmlGen# is easier to step through with a debugger.  Also, Xsd2Code uses CodeDom, whereas XmlGen# just uses WriteLine's to generate code.  XmlGen# supports multiple file output in the Visual Studio custom tool, which I prefer to single file output.

Anyways, I think the fact that the two projects accomplish similar goals using different mechanisms means that they both have value.  It's good to have choices, and I think both of these projects have made great strides in modernizing the original XSD.EXE utility.

Let me know what you all think.