Skip to content

Commit 8073f02

Browse files
committed
Check cref for null
1 parent 655c898 commit 8073f02

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/Render/BitzArt.XDoc.PlainText/PlainTextRenderer.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private string RenderXmlElement(XmlElement element)
8282
var builder = new StringBuilder();
8383

8484
var crefAttribute = element.Attributes["cref"];
85-
85+
8686
if (crefAttribute != null)
8787
{
8888
// Reference
@@ -94,7 +94,7 @@ private string RenderXmlElement(XmlElement element)
9494
// Direct inheritance
9595
return RenderDirectInheritance(element);
9696
}
97-
97+
9898
foreach (XmlNode child in element.ChildNodes)
9999
{
100100
builder.Append(Render(child));
@@ -105,7 +105,12 @@ private string RenderXmlElement(XmlElement element)
105105

106106
private string RenderReference(XmlElement element, XmlAttribute crefAttribute)
107107
{
108-
var cref = new MemberIdentifier(crefAttribute.Value);
108+
var cref = MemberIdentifier.TryCreate(crefAttribute.Value, out var result) ? result : null;
109+
110+
if (cref == null)
111+
{
112+
return string.Empty;
113+
}
109114

110115
var type = _options.UseShortTypeNames ? cref.ShortType : cref.Type;
111116

@@ -116,11 +121,11 @@ private string RenderReference(XmlElement element, XmlAttribute crefAttribute)
116121

117122
return type;
118123
}
119-
124+
120125
private string RenderDirectInheritance(XmlElement element)
121126
{
122127
//We can't now get the parent type, so we just return an empty string
123-
128+
124129
return string.Empty;
125130
}
126131
}

0 commit comments

Comments
 (0)