Skip to content

Commit

Permalink
Fix broken DataAnnotations
Browse files Browse the repository at this point in the history
Increase coverage
  • Loading branch information
Michael Ganss committed Nov 4, 2015
1 parent 208c7b1 commit 6eb98e9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
2 changes: 1 addition & 1 deletion XmlSchemaClassGenerator.Tests/XmlTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public void CanDeserializeSampleXml()
TestSamples("Client", ClientPattern);
Compile("IS24RestApi", IS24Pattern);
TestSamples("IS24RestApi", IS24Pattern);
Compile("Wadl", WadlPattern, new Generator { EntityFramework = true });
Compile("Wadl", WadlPattern, new Generator { EntityFramework = true, DataAnnotationMode = DataAnnotationMode.All });
TestSamples("Wadl", WadlPattern);
}

Expand Down
24 changes: 12 additions & 12 deletions XmlSchemaClassGenerator.Tests/xsd/client/client.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@
</xs:element>
<xs:complexType name="MainClientFieldSets">
<xs:all minOccurs="0">

<xs:element minOccurs="1" name="MainClientDetails" type="MainClientDetailsType" />
</xs:all>
</xs:complexType>
<xs:complexType name="RelatedClientFieldSets">
<xs:all minOccurs="0">

<xs:element minOccurs="1" name="RelatedClientDetails" type="RelatedClientDetailsType" />
</xs:all>
</xs:complexType>

<xs:complexType name="ClientDetailsType">
<xs:sequence>

<xs:element minOccurs="1" maxOccurs="1" name="ClientName" type="MandatoryStringType" />
<xs:element minOccurs="1" maxOccurs="1" name="IDNumber" type="MandatoryStringType" />
<xs:element minOccurs="1" maxOccurs="1" name="LegalEntity">
Expand Down Expand Up @@ -56,7 +56,7 @@
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="NameCodePairComplexType">
<xs:complexType name="NameCodePairComplexType" mixed="true">
<xs:all>
<xs:element minOccurs="0" name="Name" type="xs:string" />
<xs:element name="Code" type="xs:string" />
Expand Down Expand Up @@ -88,7 +88,7 @@
</xs:complexType>
</xs:element>
<xs:element minOccurs="1" maxOccurs="1" name="ClientParentUniqueID" type="MandatoryStringType" />

</xs:all>
</xs:complexType>
<xs:simpleType name="GUIDType">
Expand Down Expand Up @@ -117,32 +117,32 @@
<xs:restriction base="xs:string">
<xs:enumeration value="A" />
<xs:enumeration value="B" />

</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="Code">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="2" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:all>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="RoleType">
<xs:complexContent mixed="false">
<xs:complexType name="RoleType" mixed="true">
<xs:complexContent>
<xs:restriction base="NameCodePairComplexType">
<xs:all>
<xs:element minOccurs="0" name="Name">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="c" />
<xs:enumeration value="d" />

</xs:restriction>
</xs:simpleType>
</xs:element>
Expand All @@ -151,7 +151,7 @@
<xs:restriction base="xs:string">
<xs:enumeration value="3" />
<xs:enumeration value="4" />

</xs:restriction>
</xs:simpleType>
</xs:element>
Expand Down
18 changes: 1 addition & 17 deletions XmlSchemaClassGenerator/TypeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -389,23 +389,6 @@ public List<ClassModel> GetAllDerivedTypes()

return allDerivedTypes;
}

public int TotalProperties
{
get
{
var elems = 0;
var clss = this;

while (clss != null)
{
elems += clss.Properties.Count();
clss = clss.BaseClass as ClassModel;
}

return elems;
}
}
}

public class PropertyModel
Expand Down Expand Up @@ -567,6 +550,7 @@ private void AddDocs(CodeTypeMember member)
{
docs.AddRange(simpleType.Documentation);
docs.AddRange(simpleType.Restrictions.Select(r => new DocumentationModel { Language = "en", Text = r.Description }));
member.CustomAttributes.AddRange(simpleType.GetRestrictionAttributes().ToArray());
}

member.Comments.AddRange(DocumentationModel.GetComments(docs).ToArray());
Expand Down

0 comments on commit 6eb98e9

Please sign in to comment.