XmlSchemaClassGenerator
XmlSchemaClassGenerator copied to clipboard
Duplicate member in code generation
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
Does using the --tvpn, --textValuePropertyName command line argument help (e.g. set to TextValue)?