I have an existing C# file, generated a long time ago from XSD definition.
The XSD files were changed, and proxy class should be regenerated.
I've tried to use XML Schema Definition Tool (Xsd.exe)
to generate C# class, but it returned the error: "The datatype is missing".
I've actually have two XSD files -outer and imported
Note that name of generated file is combined from the files listed
I've created the batch file to be able to rerun it
@call "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat" x86
xsd.exe outer.xsd imported.xsd /classes /l:cs /n:MyNamespace
rem rename outer_imported.cs as outer.cs
By some reason the generated file created in some non-default encoding, which inserts 3 characters
ï»¿ in the beginning.It is a minor annoyance, but when I delete them, VS shows me a warning, that wrong encoding could prevent keeping history.
The next issue was that the new XSD(.Net Framework 2.0 and 3.5) generates C# classes differently with what 1.0/1.1 XSD.exe did.
In a few places 1.1 version generated custom collection of objects, but new XSD.EXE generates array of objects, so I have to change the calls to generated classes.
Another problem with XSD generated classes is that it disables step into debugging even on methods that you extended in partial classes by specifying DebuggerStepThroughAttribute
for classes. Workarounds are described in XSD.exe and DebuggerStepThrough
post. Issue reported to MS Feedback.
I should try An XSD to .NET language code class generator that adds real punch to Microsoft's XSD Tool.
or Sample Code Generator 188.8.131.52
That's pity, that minor changes in XSD file causes different class properties to be generated and essential code changes to access the new properties.