Skip to content

Commit

Permalink
Merge branch 'master' into substitution
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Ganss committed Jul 29, 2020
2 parents 749117e + c9d50ea commit 8ad9388
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,9 @@
<None Update="xsd\nullable\optional.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="xsd\simple\restriction.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="xsd\simple\simple.xsd">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private IEnumerable<string> 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";
Expand Down
11 changes: 11 additions & 0 deletions XmlSchemaClassGenerator.Tests/xsd/simple/restriction.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="module">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:schema>
15 changes: 14 additions & 1 deletion XmlSchemaClassGenerator/ModelBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 8ad9388

Please sign in to comment.