Open
Description
The xsd files from this example define enumeration restrictions for simpleType and also for complexType elements.
These enumerations for simpleType are generated correctly as C# enum:
<xsd:simpleType name = "TransResponseCodeType">
<xsd:restriction base="xsd:normalizedString">
<xsd:enumeration value="Always"/>
<xsd:enumeration value="OnError"/>
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name = "TransActionCodeEnumerationType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="Add"/>
<xsd:enumeration value="Change"/>
<xsd:enumeration value="Delete"/>
<xsd:enumeration value="Replaced"/>
<xsd:enumeration value="Accepted"/>
<xsd:enumeration value="Modified"/>
<xsd:enumeration value="Rejected"/>
</xsd:restriction>
</xsd:simpleType>
Generated c# code:
[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.1.1184.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute("TransResponseCodeType", Namespace="http://www.wbf.org/xml/B2MML-V0401")]
public enum TransResponseCodeType
{
Always,
OnError,
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.1.1184.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute("TransActionCodeEnumerationType", Namespace="http://www.wbf.org/xml/B2MML-V0401")]
public enum TransActionCodeEnumerationType
{
Add,
Change,
Delete,
Replaced,
Accepted,
Modified,
Rejected,
}
This enumeration for complexType is not generated correctly as C# enum:
<xsd:complexType name = "TransConfirma
6968
tionCodeType">
<xsd:simpleContent>
<xsd:restriction base="CodeType">
<xsd:enumeration value="Always"/>
<xsd:enumeration value="Never"/>
<xsd:enumeration value="OnError"/>
</xsd:restriction>
</xsd:simpleContent>
</xsd:complexType>
Generated c# code is just empty class:
[System.CodeDom.Compiler.GeneratedCodeAttribute("XmlSchemaClassGenerator", "2.1.1184.0")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute("TransConfirmationCodeType", Namespace="http://www.wbf.org/xml/B2MML-V0401")]
[System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class TransConfirmationCodeType : MyData.CodeType
{
}
This is the CodeType definition in the xsd schema file
<!-- **************************************** -->
<!-- CodeType used for any enumerated strings -->
<!-- **************************************** -->
<xsd:complexType name="CodeType">
<xsd:simpleContent>
<xsd:extension base="xsd:normalizedString">
<xsd:attribute name="listID" type="xsd:normalizedString" use="optional" />
<xsd:attribute name="listAgencyID" type="xsd:normalizedString" use="optional" />
<xsd:attribute name="listAgencyName" type="xsd:string" use="optional" />
<xsd:attribute name="listName" type="xsd:string" use="optional" />
<xsd:attribute name="listVersionID" type="xsd:normalizedString" use="optional" />
<xsd:attribute name="name" type="xsd:string" use="optional" />
<xsd:attribute name="languageID" type="xsd:language" use="optional" />
<xsd:attribute name="listURI" type="xsd:anyURI" use="optional" />
<xsd:attribute name="listSchemeURI" type="xsd:anyURI" use="optional" />
</xsd:extension>
</xsd:simpleContent>
</xsd:complexType>
This is how the generated C# code could more or less look like:
public enum TransConfirmationCodeEnum
{
Always,
Never,
OnError
}
public class TransConfirmationCodeType : CodeType
{
[XmlIgnore]
public new string Value
{
get => EnumValue.ToString();
set => EnumValue = Enum.Parse<TransConfirmationCodeEnum>(value, ignoreCase: true);
}
[XmlText]
public TransConfirmationCodeEnum EnumValue { get; set; }
}
Metadata
Metadata
Assignees
Labels
No labels