How can I ignore/remove the "order" attribute from the datamember generated.

Apr 29, 2014 at 8:02 AM
Edited Apr 29, 2014 at 8:03 AM
Here is the story,

I worked with VS2010 with a old version of XSD2Code, and it works perfectly (just a problem of a bunch of nullable<?> properties get generated). Recently, I began to use VS2013 with the latest version of this plugin "3.4.0.37595". I differ the generated file and found all datamembers have a new attribute "order" like [System.Xml.Serialization.XmlElementAttribute("entries", Form = System.Xml.Schema.XmlSchemaForm.Unqualified, Order = 0)].

The thing is, as all generated classes are "partial", so we create a bunch of partical class with our own and add some new properties. And it stops working anymore with the error "Inconsistent sequencing: if used on one of the class's members, the 'Order' property is required on all particle-like members, please explicitly set 'Order' using XmlElement, XmlAnyElement or XmlArray custom attribute on class member 'XXX'."

To make it clear,
Auto generated class:
public partial class A : EntityBase<A>{
public int someProperty
}

Manually created classes:
public partial class A : EntityBase<A>{
public int newProperty{get;set;}
}

Because the xsd file is generated from a 3rd application, so we cannot change it, and this leads to the problem that we have to add a bunch of new properties that will only used by us.

The solution is, I have to add the XMLIgnore attribute for this new property, this should be fine, however, as we have so many partial class and new properties, so it is easy to miss someone and leads to some bugs.

So the workaround I am using is remove all "Order" attribute from the generated class via a "Search & Replace" way.

I am wondering is there any other way I can go to fix this problem instead of using a workaround (every time the file get generated, we need to re-do the search & replace process)

Regards,