Skip to content

Commit

Permalink
Improve support for groups (fix #109)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Mar 28, 2019
1 parent a01f5bd commit 282893b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaComplexType complexType,
// If it's a restriction, do not duplicate elements on the derived class, they're already in the base class.
// See https://msdn.microsoft.com/en-us/library/f3z3wh0y.aspx
}
else particle = complexType.ContentTypeParticle;
else particle = complexType.Particle ?? complexType.ContentTypeParticle;

var items = GetElements(particle, complexType);
var properties = CreatePropertiesForElements(source, classModel, particle, items);
Expand Down Expand Up @@ -479,6 +479,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
{
var properties = new List<PropertyModel>();
var order = 0;

foreach (var item in items)
{
PropertyModel property = null;
Expand All @@ -495,7 +496,8 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
if (elementQualifiedName.IsEmpty)
{
// inner type, have to generate a type name
var typeName = _configuration.NamingProvider.PropertyNameFromElement(typeModel.Name, element.QualifiedName.Name);
var typeModelName = particle is XmlSchemaGroupRef groupRef ? groupRef.RefName : typeModel.XmlSchemaName;
var typeName = _configuration.NamingProvider.PropertyNameFromElement(typeModelName.Name, element.QualifiedName.Name);
elementQualifiedName = new XmlQualifiedName(typeName, typeModel.XmlSchemaName.Namespace);
// try to avoid name clashes
if (NameExists(elementQualifiedName))
Expand Down

0 comments on commit 282893b

Please sign in to comment.