diff --git a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj
index 6a951be9..4445d2a5 100644
--- a/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj
+++ b/XmlSchemaClassGenerator.Tests/XmlSchemaClassGenerator.Tests.csproj
@@ -873,6 +873,9 @@
PreserveNewest
+
+ PreserveNewest
+
PreserveNewest
diff --git a/XmlSchemaClassGenerator.Tests/XmlTests.cs b/XmlSchemaClassGenerator.Tests/XmlTests.cs
index a9877154..8ba35e45 100644
--- a/XmlSchemaClassGenerator.Tests/XmlTests.cs
+++ b/XmlSchemaClassGenerator.Tests/XmlTests.cs
@@ -84,7 +84,7 @@ private IEnumerable ConvertXml(string name, string xsd, Generator genera
const string IS24ImmoTransferPattern = @"xsd\is24immotransfer\is24immotransfer.xsd";
const string WadlPattern = @"xsd\wadl\*.xsd";
const string ListPattern = @"xsd\list\list.xsd";
- const string SimplePattern = @"xsd\simple\simple.xsd";
+ const string SimplePattern = @"xsd\simple\*.xsd";
const string ArrayOrderPattern = @"xsd\array-order\array-order.xsd";
const string ClientPattern = @"xsd\client\client.xsd";
const string IataPattern = @"xsd\iata\*.xsd";
diff --git a/XmlSchemaClassGenerator.Tests/xsd/simple/restriction.xsd b/XmlSchemaClassGenerator.Tests/xsd/simple/restriction.xsd
new file mode 100644
index 00000000..47c52e0e
--- /dev/null
+++ b/XmlSchemaClassGenerator.Tests/xsd/simple/restriction.xsd
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/XmlSchemaClassGenerator/ModelBuilder.cs b/XmlSchemaClassGenerator/ModelBuilder.cs
index 57e6042e..228536e5 100644
--- a/XmlSchemaClassGenerator/ModelBuilder.cs
+++ b/XmlSchemaClassGenerator/ModelBuilder.cs
@@ -468,7 +468,20 @@ private TypeModel CreateTypeModel(Uri source, XmlSchemaComplexType complexType,
// If it's a restriction, do not duplicate attributes on the derived class, they're already in the base class.
// See https://msdn.microsoft.com/en-us/library/f3z3wh0y.aspx
}
- else { attributes = complexType.Attributes; }
+ else
+ {
+ attributes = complexType.Attributes;
+
+ if (attributes.Count == 0 && complexType.ContentModel != null)
+ {
+ var content = complexType.ContentModel.Content;
+
+ if (content is XmlSchemaComplexContentExtension extension)
+ attributes = extension.Attributes;
+ else if (content is XmlSchemaComplexContentRestriction restriction)
+ attributes = restriction.Attributes;
+ }
+ }
if (attributes != null)
{