Browse Source

Fix #2500: NRE and other bugs when hovering over symbol with <inheritdoc />.

pull/2509/head
Siegfried Pammer 4 years ago
parent
commit
6628e0a410
  1. 11
      ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs

11
ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs

@ -190,23 +190,24 @@ namespace ICSharpCode.Decompiler.Documentation
{ {
if (nestingLevel < 5 && childElement.Name == "inheritdoc") if (nestingLevel < 5 && childElement.Name == "inheritdoc")
{ {
string cref = childElement.Attribute("cref").Value; string? cref = childElement.Attribute("cref")?.Value;
IEntity? inheritedFrom = null; IEntity? inheritedFrom = null;
string? inheritedDocumentation = null; string? inheritedDocumentation = null;
if (cref != null && crefResolver != null) if (cref != null && crefResolver != null)
{ {
inheritedFrom = crefResolver(cref); inheritedFrom = crefResolver(cref);
if (inheritedFrom != null) if (inheritedFrom != null)
inheritedDocumentation = inheritedFrom.GetDocumentation(); inheritedDocumentation = "<doc>" + inheritedFrom.GetDocumentation() + "</doc>";
} }
else else
{ {
foreach (IMember baseMember in InheritanceHelper.GetBaseMembers((IMember)declaringEntity, includeImplementedInterfaces: true)) foreach (IMember baseMember in InheritanceHelper.GetBaseMembers((IMember?)declaringEntity, includeImplementedInterfaces: true))
{ {
inheritedDocumentation = baseMember.GetDocumentation(); inheritedDocumentation = baseMember.GetDocumentation();
if (inheritedDocumentation != null) if (inheritedDocumentation != null)
{ {
inheritedFrom = baseMember; inheritedFrom = baseMember;
inheritedDocumentation = "<doc>" + inheritedDocumentation + "</doc>";
break; break;
} }
} }
@ -214,10 +215,10 @@ namespace ICSharpCode.Decompiler.Documentation
if (inheritedDocumentation != null) if (inheritedDocumentation != null)
{ {
var doc = XDocument.Parse(inheritedDocumentation); var doc = XDocument.Parse(inheritedDocumentation).Element("doc");
// XPath filter not yet implemented // XPath filter not yet implemented
if (childElement.Parent == null && childElement.Attribute("select").Value == null) if (childElement.Parent?.Parent == null && childElement.Attribute("select")?.Value == null)
{ {
// Inheriting documentation at the root level // Inheriting documentation at the root level
List<string> doNotInherit = new List<string>(); List<string> doNotInherit = new List<string>();

Loading…
Cancel
Save