XML Serialization and enums
Well, I was looking what ASP.NET web services generates when I have an enum parameter. Consider the following type:
public enum MyEnum : int
{
EnumValue1 = 0,
EnumValue2 = 2
}
I'm expecting something like
<xs:simpleType name="MyEnum">
<xs:restriction base="xs:int">
<xs:enumeration value="0" />
<xs:enumeration value="2" />
</xs:restriction>
</xs:simpleType>
But the xsd produces:
<xs:simpleType name="MyEnum">
<xs:restriction base="xs:string">
<xs:enumeration value="EnumValue1" />
<xs:enumeration value="EnumValue2" />
</xs:restriction>
</xs:simpleType>
Even if I'm decorating the enum values with System.Xml.Serialization.XmlEnumAttribute I can't get back an XML schema with a restriction of int instead of string. Why DataType of XmlElementAttribute doesn't work from primitives ? I don't know, but today I have to edit the WSDL manually.