Strange behaviour on enums in the xsd metadata

Hi, here is the strange behaviour :
if I declare an enum like this

namespace mynamepsace
{
public enum LockedstatusReason
{
NotLocked = 0,
ShiftStarted = 1,
AcceptanceExpired = 2
}
}

and i have

[assembly: ContractNamespace(“http://anothernamespace”. ClrNamespace = “mynamepsace”)]

the xsd for the enum is emitted in
http://schemas.datacontract.org/2004/07/anothernamespace
and the xml schema does contains the allowed enumerated values

<xs:simpleType name=“LockedstatusReason”>
xs:list
xs:simpleType

<xs:restriction base="xs:string">
<xs:enumeration value="NotLocked">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">0</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="ShiftStarted">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">1</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="AcceptanceExpired">
<xs:annotation>
<xs:appinfo>
<EnumerationValue xmlns="http://schemas.microsoft.com/2003/10/Serialization/">2</EnumerationValue>
</xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
</xs:list>
</xs:simpleType>

.------

IF i add a datacontract attribute to the enum , it goes correctly to
http://anothernamespace
BUT it does not contain the enumerated values :

<xs:simpleType name="LockedstatusReason">
<xs:list>
<xs:simpleType>
<xs:restriction base="xs:string"/>
</xs:simpleType>
</xs:list>
</xs:simpleType>

how is that ?
thank you
enrico

Please note the behavior of XSD uses .NET DataContract and is fixed and limited to what XsdDataContractExporter allows. You should check the MSDN docs for information on Enum Types in DataContract, which looks like you need to export the enum values with [EnumMember].

yes , adding the enum attribute did the trick …

However the way the enum are emitted in the xsd when they do not have the datacontract attribute is weird :
enum values are emittes without the need for the EnumMember attribute, but they are emitted in the “wrong” namespace.

bye