Xsd Generator with GAT (generate a class from an xml schema)

UPDATE: I've updated the GAT package and created the GotDotNet workspace. See this post.

 

I've started working on GAT recipes because of a project called blueprint that we are doing here at Southworks.

 

So here is my first attempt. After 1 day I’ve built something that would have been very useful in the old days.

The recipe is a simple xsd to class generator by just right-click on *.xsd files (no wizards, no input). I thought that Whidbey was going to improve xsd.exe but it didn’t. It is just the same as before but with property generation instead of fields.

Today there are some of these tools already, but I always wanted to have my own “xsd.exe” to customize it a piacere.

So I picked this idea from this article in msdn (written by kzu) and created my guidance package.

 

This is a very first version that generates a c# entity by right clicking the xsd on a project. It still needs some refactoring, some fixes and some missing features, but it works. My assignment was to make a proof of concept on the GAT technology and provide feedback about it to the blueprint architect. We believe that GAT recipes are great because they are more user friendly than using VS external tools.

 

The current features are:

  • Generates c# class/es by right click on the xsd on a project
  • Uses System.Collections.Generic.List instead of arrays
  • Lazy initialization of generic collections (on property getters)
  • Class takes the default namespace of the project

 Coming features:

  • Right click the project and generates all classes for every xsd on the project
  • Another command bar to generate in vb.net

 Known bugs:

  • Generate for a second time if the target file already exist will throw an exception

Requirements:

Download the MSI and install the GAT package XsdToEntityPackageSetup.zip (202.49 KB)

 

Remember to enable the package in vs 2005: Tools -> Guidance Package Manager -> Enable/Disable Packages. Choose the one that says “Generates a class from xsd”.

Published: July 15 2005

blog comments powered by Disqus