Provide list of members that Xsd2Code does NOT generate code for..

Nov 4, 2009 at 1:57 PM
Edited Nov 4, 2009 at 1:58 PM

Hi there

 

In my example here I have an enum that I want serialized with certain values..

  <xs:simpleType name="MonthsEnum">
    <xs:restriction base="xs:string">
      <xs:enumeration value="January" />
      <xs:enumeration value="February" />
...
      <xs:enumeration value="December" />
    </xs:restriction>
  </xs:simpleType>

The code is made:

public enum MonthsEnum{

  January,

  February,

...

  December,

}

 

Now I want to decorate:

public enum MonthsEnum{

  [XmlEnum("01")]
  January,

  [XmlEnum("02")]
  February,

...

  [XmlEnum("12")]
  December,

}

 

But Xsd2Code will overwrite this all the time, so I move it to the partial class that I control

But now xsd2code generates it all the time and we get "XYZNamespace already contains a definition for MonthsEnum"

So I delete it from the generated code, but it is a headache coming in to delete it (and all the others I moved to partial class) every time I generate.. If there was a way to have xsd2code have an ignore list so I can set an ignore of MonthsEnum, or MyElement.SubElementStringCDATA (for the other guy who is asking for xsd2code to generate the hacked way of making XmlSerializer do CDATA.. he can put his hack into the partial he controls and then just use the ignore function of xsd2code..) that would be great..