Thursday, November 5, 2009

 

XSD to Class generation in .Net

Visual Studio comes with a very handy tool called XSD.Exe. It helps to generate a C# class from a XML Schema (xsd). Once you have the class its very easy to serialize / de-serialize XML instances. Personally I find two thing very annoying in the code generated by xsd:

1. For collection types Xsd.exe generates an array definition instead of List generic.

2. By default it marks the code generated as “not Debuggable” !!!, you’ll be surprised that you cannot step-in the generated class by default.

After having faced this two problem 4-5 times, I decided to write some helper tool to solve these. Took the simple path of writing two macros in visual studio. One for removing the “not Debuggable” [aka System.Diagnostics.DebuggerStepThroughAttribute()] and other to convert every field/property of array type to List.

The macro code is available at my Aha e-Assets page.


This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]