XSD for C# enum class

I am generating a class with XSD.EXE from a schema. I am summarizing the posting only the part of the schema that generates the enum that I have doubts.

<xs:simpleType name="TCodUfIBGE">
    <xs:annotation>
        <xs:documentation>Tipo Código da UF da tabela do IBGE</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
        <xs:whiteSpace value="preserve"/>
        <xs:enumeration value="11"/>
        <xs:enumeration value="12"/>
        <xs:enumeration value="13"/>
        <xs:enumeration value="14"/>
        <xs:enumeration value="15"/>
        <xs:enumeration value="16"/>
        <xs:enumeration value="17"/>
        <xs:enumeration value="21"/>
        <xs:enumeration value="22"/>
        <xs:enumeration value="23"/>
        <xs:enumeration value="24"/>
        <xs:enumeration value="25"/>
        <xs:enumeration value="26"/>
        <xs:enumeration value="27"/>
        <xs:enumeration value="28"/>
        <xs:enumeration value="29"/>
        <xs:enumeration value="31"/>
        <xs:enumeration value="32"/>
        <xs:enumeration value="33"/>
        <xs:enumeration value="35"/>
        <xs:enumeration value="41"/>
        <xs:enumeration value="42"/>
        <xs:enumeration value="43"/>
        <xs:enumeration value="50"/>
        <xs:enumeration value="51"/>
        <xs:enumeration value="52"/>
        <xs:enumeration value="53"/>
    </xs:restriction>
</xs:simpleType>

In the class is looking like this:

Note: also summarized.

 public enum TCodUfIBGE
 {

    /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("11")]
    Item11,

    /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("12")]
    Item12,

    /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("13")]
    Item13,
 }

Example:

 /// <remarks/>
    [System.Xml.Serialization.XmlEnumAttribute("11")]
    Item11 = 11,

Or else:

public enum TipoPessoa
{
   [System.Xml.Serialization.XmlEnumAttribute("1")]
    Fisica = 1,
   [System.Xml.Serialization.XmlEnumAttribute("2")]
    Juridica = 2
}

EDIT: Is there any way to generate this class with the values referring to the items of the defined enum equal to those of the attribute?

Why in a real application would this be absurd ?

Author: Robss70, 2016-09-21

1 answers

I solved the problem as follows.

When you open schema in VS you notice some reference problems:


insert the description of the image here


Somehow this problem of FileioPermission affects the generation of the class by xsd (xsd xmldsig-core-schema_v1.01.xsd nfe_v3.10.xsd /c)

To get around the problem it is necessary desbloquear the file and remove the permission somente leitura (I did this all the files of shcema)

insert the description of the image here


Can now generate the class again (xsd xmldsig-core-schema_v1.01.xsd nfe_v3.10.xsd /c) and you will see that it is possible to define the types that were previously unrecognized according to the image:


insert the description of the image here


Source: https://stackoverflow.com/questions/3134352/how-do-i-modify-my-settings-to-allow-vs2010-to-load-3rd-party-xsd-files-from-the

 5
Author: rubStackOverflow, 2017-05-23 12:37:31