Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate member in code generation #165

Open
thespooler opened this issue Feb 11, 2020 · 1 comment
Open

Duplicate member in code generation #165

thespooler opened this issue Feb 11, 2020 · 1 comment

Comments

@thespooler
Copy link

Given the following schema:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="test" targetNamespace="urn:test" 
    xmlns="urn:test" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="Test">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="Value" type="xs:string" use="required" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:schema>

In the method XmlSchemaClassGenerator.ClassModel.Generate(), the code will go through

    if (BaseClass != null) { 
    ... 
        else if (!string.IsNullOrEmpty(Configuration.TextValuePropertyName)) { ... }
    }

and also in

    foreach (var property in Properties.GroupBy(x => x.Name)) { ... }

generating the following class with the Value attribute appearing twice.

...
    public partial class Test
    {
        [System.Xml.Serialization.XmlTextAttribute()]
        public string Value { get; set; }
        
        [System.Xml.Serialization.XmlAttributeAttribute("Value", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
        public string Value { get; set; }
    }

Command used: XmlSchemaClassGenerator.Console.exe -n "urn:test"=Test Test.xsd

@thespooler thespooler changed the title Invalid code generation Duplicate member in code generation Feb 11, 2020
@mganss
Copy link
Owner

mganss commented Feb 12, 2020

Does using the --tvpn, --textValuePropertyName command line argument help (e.g. set to TextValue)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants