I want to svcutil to export metadata from my libraries into one xsd file. As it divides metadata into different files by namespace, I want to redefine it for all classes to sole namespace. I can "try" do it by two ways: 1) Redefine it for each class in DataContract attribute like this [DataContract(Namespace="http://mynamspace.com")] but i get the next obstacle - I can't set atribute on class that is derived from standard class
2)Redefine namespace for each namespace in assembly, which includes exporting classes. [assembly: ContractNamespaceAttribute(SerializationConstants.DefaultNamespace, ClrNamespace = "UBP.AddInfo")] But here, I challenge another problem - this directive doesn't reflect on enumeratons. They remain being exported into namespace as it defined in assembly. So it forced me to set attribute DataContract to these enums directly. BUT!!!! in this case enumeration is exported incorrectly. Instead of
<xs:simpleType name="AddInfoValueType">
<xs:restriction base="xs:string">
<xs:enumeration value="String" />
<xs:enumeration value="DateTime" />
<xs:enumeration value="Number" />
<xs:enumeration value="BynaryData" />
</xs:restriction>
</xs:simpleType>
I get
<xs:simpleType name="AddInfoValueType">
<xs:restriction base="xs:string" />
</xs:simpleType>
Has anyone challenged such problems?
This is generally the route I'd go - gives you precise control. And the issue with deriving from a system type. There is an old joke Man: "doctor doctor it hurts when I do this" Doctor: "Then don't do it". I'd avoid deriving from system types on my service boundaries and just define the data you want to transport. Obviously I don't know your exact situation but that's the general approach I'd take
You can mix and match the two approaches - You should be able to annotate the enums with [DataContract]
and each enum member with [EnumMember]
and that should give you what you need