Skip to content

Commit 56cf97b

Browse files
committed
Update EnsureReferencability.cs
Ensure that all ReferenceType qnames end with Reference
1 parent b9e1eda commit 56cf97b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

Colectica.DDISchemaCheck.Checks/EnsureReferencability.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ public static string GetTestResult(XmlSchemaSet schema)
2525
List<Tuple<XmlQualifiedName, XmlSchemaElement>> noChoice = new List<Tuple<XmlQualifiedName, XmlSchemaElement>>();
2626
List<Tuple<XmlQualifiedName, XmlSchemaElement>> wrongFormatChoice = new List<Tuple<XmlQualifiedName, XmlSchemaElement>>();
2727
List<Tuple<XmlQualifiedName, XmlSchemaElement>> wrongNumberChoice = new List<Tuple<XmlQualifiedName, XmlSchemaElement>>();
28+
29+
List<Tuple<XmlQualifiedName, XmlSchemaElement>> noReferencePrefix = new List<Tuple<XmlQualifiedName, XmlSchemaElement>>();
2830
foreach (var tuple in elementsFound)
2931
{
3032
XmlSchemaElement element = tuple.Item2;
@@ -74,6 +76,14 @@ public static string GetTestResult(XmlSchemaSet schema)
7476

7577
}
7678
}
79+
80+
if (ct.AttributeUses.Values.Cast<XmlSchemaAttribute>().Any(a => a.Name == "isReference"))
81+
{
82+
if (!element.QualifiedName.Name.EndsWith("Reference"))
83+
{
84+
noReferencePrefix.Add(tuple);
85+
}
86+
}
7787
}
7888

7989
StringBuilder b = new StringBuilder();
@@ -167,6 +177,34 @@ public static string GetTestResult(XmlSchemaSet schema)
167177
b.Append("<div class=\"alert alert-success\">Correct number of elements in all Versionables and Maintainables referenceable xs:Choice format.</div>");
168178
}
169179

180+
181+
if (noReferencePrefix.Count > 0)
182+
{
183+
b.Append(@"<div class=""alert alert-danger"">A ReferenceType should end in ""Reference"".</div>");
184+
b.AppendLine(@"<table class=""table"">
185+
<thead>
186+
<tr>
187+
<th>#</th>
188+
<th>Item</th>
189+
<th>No ending Reference</th>
190+
</tr>
191+
</thead>
192+
<tbody>");
193+
int i = 1;
194+
195+
foreach (var n in noReferencePrefix.OrderBy(x => x.Item1.ToString()))
196+
{
197+
b.Append(string.Format(tableRow,
198+
i++,
199+
n.Item2.QualifiedName.ToString(),
200+
n.Item1.ToString()));
201+
}
202+
b.AppendLine("</table>");
203+
}
204+
else
205+
{
206+
b.Append("<div class=\"alert alert-success\">All ReferenceTypes end with \"Reference\".</div>");
207+
}
170208
return b.ToString();
171209
}
172210
}

0 commit comments

Comments
 (0)