When using XSD.exe /c /l:CS /o:temp /order, it doesn't generate the correct order for choices that are in a Items[]
array.
XSD:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:group name="Group">
<xsd:sequence>
<xsd:element name="BItem2"/>
<xsd:element name="AItem1"/>
</xsd:sequence>
</xsd:group>
<xsd:element name="MyElement" type="MyClass"/>
<xsd:complexType name="MyClass">
<xsd:sequence>
<xsd:choice>
<xsd:element name="Whatever"/>
<xsd:group ref="Group"/>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
Will output this:
[System.Xml.Serialization.XmlElementAttribute("AItem1", typeof(object), Order=0)]
[System.Xml.Serialization.XmlElementAttribute("BItem2", typeof(object), Order=0)]
[System.Xml.Serialization.XmlElementAttribute("Whatever", typeof(object), Order=0)]
[System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
public object[] Items {
// ..
}
In this case, the XSD generated Order=0 for all XmlElementAttribute and it ordered it alphabetically. BItem2 should be before AItem1.
Is there a way to get this working properly? I can't change the XSD as it comes from a third party.