Skip to content

Commit

Permalink
Do not generate properties with duplicate XmlSchemaNames (see #315)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Apr 4, 2022
1 parent 7576f89 commit 4b89ec3
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -454,18 +454,19 @@ public override CodeTypeDeclaration Generate()
keyProperty.IsKey = true;
}

foreach (var property in Properties.GroupBy(x => x.Name))
foreach (var property in Properties.GroupBy(x => x.Name).Select(g => g.Select((p, i) => (Property: p, Index: i)).ToList()))
{
var propertyIndex = 1;

foreach (var p in property)
{
if (propertyIndex > 1)
foreach (var p in property)
{
if (p.Index > 0)
{
p.Name += $"_{propertyIndex}";
p.Property.Name += $"_{p.Index + 1}";

if (property.Any(q => p.Property.XmlSchemaName == q.Property.XmlSchemaName && q.Index < p.Index))
continue;
}
p.AddMembersTo(classDeclaration, Configuration.EnableDataBinding);
propertyIndex++;

p.Property.AddMembersTo(classDeclaration, Configuration.EnableDataBinding);
}
}

Expand Down

0 comments on commit 4b89ec3

Please sign in to comment.