This custom tool is a wrapper class to run XSD.exe and generate a Class object instead of a DataTable object.
This was made because XSD files when imported to VS automatically generate DataSets, which can conflict with the classes XSD.exe exports if under the same namespace.
...
This VS extension is essentially a wrapper for Microsoft's XSD.exe tool.
Microsoft themselves use XSD.exe for the default XSD CustomTool (MSDataSetGenerator) assigned to .XSD files in Visual Studio.
The idea behind this tool is that MSDataSetGenerator does not provide any user customizability, and only generates DataSet style files.
For the projects I was working on, DataSets didn't make sense since these were all one-off parameters for a settings file.
Frankly, I got tired of regenerating the files using command prompt, and found that the parameter file that gets fed into XSD.exe doesn't allow full use of the capabilities. Thus this project was born.
What It Does
At its heart, this is a SingleFileGenerator that passes the assigned XSD file into XSD.exe and returns the resulting file.
Two files will always be generated when the XSD is updated:
{InputFileName}_Parameters.xml -> This file is read as an options file to configure how you want auto-generated code to look.
{InputFileName}_Autogenerated.cs -> This file is the file generated by XSD.exe. Note that the file extension changes depending on the output language.
Two additional files get generated only if they are missing on disk.
{InputFileName}_Autogenerated_Supplement.cs
xsd.exe generates partial classes that do not include constructors.
This supplement evaluates the file xsd.exe churns out, then builds itself in a similar fashion, but it includes the constructors and a way to set the base values for all the properties.
{InputFileName}_HelperClass.cs
Since the output of xsd.exe is quite ugly, this class is created as a wrapper for that class.
This also includes method for serializing and deserializing (saving/loading) from a file.
How It Works
This uses CodeDom to generate most of the code, so any language supported by CodeDom (which is what XSD.exe uses) will be able to be supported by this extension.
What I've found is that the languages that implement CodeDom don't have parser functionality, so a parser will have to be written. That parser will generate a CodeCompileUnit, which allows translation to all the secondary file generation methods.
Currently, only the C# parser is functional, so only the C# language will output the secondary files. But, this can still be used to generate the output of XSD.exe.
How to Use it
Open up the 'Properties' of any XSD file in Visual Studio Solution Explorer and you will see a field for 'CustomTool', which likely has MSDataSetGenerator as the value.
Simply replace "MSDataSetGenerator" with "XSDCustomTool", then save the xsd file.
Note: The files generated by MSDataSetGenerator WILL conflict with the files generated by this custom tool since the class names are both generated by xsd.exe. Just delete the files generated prior to running this tool. If you want them back, you can either set it back to using MSDataSetGenerator, or you can toggle the parameter file to generate a DataSet instead of a class.
Looking Forward
Currently, I am only writing in C#, which is also the default output language of xsd.exe, but xsd.exe does support VB, J#, and JS as well.
If you would like to use this tool for those other languages, I have put the framework in place, but would greatly appreciate some help getting those parsers set up!