@@ -245,7 +245,7 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaComplexType complexType,
245245 // If it's a restriction, do not duplicate elements on the derived class, they're already in the base class.
246246 // See https://msdn.microsoft.com/en-us/library/f3z3wh0y.aspx
247247 }
248- else particle = complexType . ContentTypeParticle ;
248+ else particle = complexType . Particle ?? complexType . ContentTypeParticle ;
249249
250250 var items = GetElements ( particle , complexType ) ;
251251 var properties = CreatePropertiesForElements ( source , classModel , particle , items ) ;
@@ -479,6 +479,7 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
479479 {
480480 var properties = new List < PropertyModel > ( ) ;
481481 var order = 0 ;
482+
482483 foreach ( var item in items )
483484 {
484485 PropertyModel property = null ;
@@ -495,7 +496,8 @@ private IEnumerable<PropertyModel> CreatePropertiesForElements(Uri source, TypeM
495496 if ( elementQualifiedName . IsEmpty )
496497 {
497498 // inner type, have to generate a type name
498- var typeName = _configuration . NamingProvider . PropertyNameFromElement ( typeModel . Name , element . QualifiedName . Name ) ;
499+ var typeModelName = particle is XmlSchemaGroupRef groupRef ? groupRef . RefName : typeModel . XmlSchemaName ;
500+ var typeName = _configuration . NamingProvider . PropertyNameFromElement ( typeModelName . Name , element . QualifiedName . Name ) ;
499501 elementQualifiedName = new XmlQualifiedName ( typeName , typeModel . XmlSchemaName . Namespace ) ;
500502 // try to avoid name clashes
501503 if ( NameExists ( elementQualifiedName ) )
0 commit comments