Skip to content

Commit

Permalink
Always iterate over groups, no matter the count (saves one or two Ge…
Browse files Browse the repository at this point in the history
…tEnumerator calls).
  • Loading branch information
jokokko committed Oct 9, 2018
1 parent 73239a0 commit df3be5b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -385,19 +385,16 @@ public override CodeTypeDeclaration Generate()

foreach (var property in Properties.GroupBy(x => x.Name))
{
property.First().AddMembersTo(classDeclaration, Configuration.EnableDataBinding);

if (property.Count() > 1)
{
var propertyIndex = 1;
foreach (var n in property.Skip(1))
var propertyIndex = 0;
foreach (var p in property)
{
if (propertyIndex > 0)
{
n.Name += $"_{propertyIndex}";
propertyIndex++;
n.AddMembersTo(classDeclaration, Configuration.EnableDataBinding);
p.Name += $"_{propertyIndex}";
}
}

p.AddMembersTo(classDeclaration, Configuration.EnableDataBinding);
propertyIndex++;
}
}

if (IsMixed && (BaseClass == null || (BaseClass is ClassModel && !AllBaseClasses.Any(b => b.IsMixed))))
Expand Down

0 comments on commit df3be5b

Please sign in to comment.