views:

205

answers:

2

I am using xsd.exe to generate a C# class from a collection of xsd files. The xsd file makes use of the <xsd:documentation> tag to include useful descriptions. Example:

<xsd:complexType name="AddressType">
    <xsd:annotation>
        <xsd:documentation>A formatted or free form address and its intended use.</xsd:documentation>
    </xsd:annotation>

Unfortunately all of this is lost in the generated C# class. Interestingly each class has an empty remarks documentation tag attached to it.

/// <remarks/>

Ideally I would like to find a solution (doesn't have to be with .NET's xsd.exe) that includes this documentation in the generated C# class (either in or documentation tags). It could be a post processor or an entirely different process. Anything short of me adding them manually!

+2  A: 

Sorry, there's no way to do this.

John Saunders
No way to do it with xsd.exe or no way to do it with any tool?
Jim McKeeth
"Any sufficiently advanced technology is indistinguishable from magic". I'm sure you could write a tool to do it.
John Saunders
Are there other tools that do the XSD to C# magic besides XSD.exe? I saw a reference to XSDObjectGen, but the only download I could find for it was from 2006. Does it still work? +1 for Clarke reference.
Jim McKeeth
There is a built-in technology in Visual Studio. See http://msdn.microsoft.com/en-us/library/bb126445.aspx, and ignore the mention of the DSL Tools (for now). The hint is that you'd want to consume a set of XSDs using the .NET System.Xml.Schema APIs, then use that schema set as input to a T4 template, which could generate code.
John Saunders
+1  A: 

xsd.exe is based on Codedom.

You could disassemble xsd.exe, and add the functionality there and recompile. The code is reasonably simple.

I had modified it to skip some namespaces from xsd while generating code.[Otherwise If I include a common.xsd in 2 other xsds the class was getting generated twice.]

Granted, I had access to source proper itself [I was a developer at Microsoft], but the process should be simple with diassembled code as well.

Fakrudeen