I am trying to use xsd or xsd2code to generate a c# class from an XSD file. The XSD file is from a third party, and cannot be modified.
It does generate classes, but they include blocks like this.
[XmlElement("ABOUT_VERSIONS", typeof(ABOUT_VERSIONS), Order=0)]
[XmlElement("ASSETS", typeof(ASSETS), Order=0)]
[XmlElement("COLLATERALS", typeof(COLLATERALS), Order=0)]
[XmlElement("COMMUNICATION_EVENTS", typeof(COMMUNICATION_EVENTS), Order=0)]
[XmlElement("DEAL_DETAIL", typeof(DEAL_DETAIL), Order=0)]
[XmlElement("EXPENSES", typeof(EXPENSES), Order=0)]
[XmlElement("EXTENSION", typeof(DEAL_EXTENSION), Order=0)]
[XmlElement("LIABILITIES", typeof(LIABILITIES), Order=0)]
[XmlElement("LITIGATIONS", typeof(LITIGATIONS), Order=0)]
[XmlElement("LOANS", typeof(LOANS), Order=0)]
[XmlElement("PARTIES", typeof(PARTIES), Order=0)]
[XmlElement("REFERENCE", typeof(REFERENCE), Order=0)]
[XmlElement("RELATIONSHIPS", typeof(RELATIONSHIPS), Order=0)]
[XmlElement("SERVICES", typeof(SERVICES), Order=0)]
[XmlElement("SUPPORTING_RECORD_SETS", typeof(SUPPORTING_RECORD_SETS), Order=0)]
public List<object> Items { get; set; }
In simpler classes in the past I have just manually edited the output to make the classes useful, replacing it with something like this
[XmlElement("ABOUT_VERSIONS", typeof(ABOUT_VERSIONS), Order=0)])]
public List<ABOUT_VERSIONS> ABOUT_VERSIONS { get; set; }
[XmlElement("ASSETS", typeof(ASSETS), Order=0)])]
public List<ASSETS> ASSETS { get; set; }
...
This output is incredibly large (nearly 9MB of output class file), and the output is full of similar blocks. It would take days to go through and manually edit the auto generated classes, only to have to do it again the next time they release an update (This is the MISMO message standard if you are curious. It is an xml data transfer standard written by a bunch of non-technical banking executives. It is probably worse than you are thinking.).
So is there a way to force xsd or xsd2code, or some other tool, to auto-generate c# classes that separate each of the possible child classes into their own list rather than clumping them together into an object list?