From 6628e0a410f488b84ba0f0d1c2812dafe17a8c00 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 19 Sep 2021 19:50:17 +0200 Subject: [PATCH] Fix #2500: NRE and other bugs when hovering over symbol with . --- .../Documentation/XmlDocumentationElement.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs b/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs index ab1714e2a..9b6b51ac0 100644 --- a/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs +++ b/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs @@ -190,23 +190,24 @@ namespace ICSharpCode.Decompiler.Documentation { if (nestingLevel < 5 && childElement.Name == "inheritdoc") { - string cref = childElement.Attribute("cref").Value; + string? cref = childElement.Attribute("cref")?.Value; IEntity? inheritedFrom = null; string? inheritedDocumentation = null; if (cref != null && crefResolver != null) { inheritedFrom = crefResolver(cref); if (inheritedFrom != null) - inheritedDocumentation = inheritedFrom.GetDocumentation(); + inheritedDocumentation = "" + inheritedFrom.GetDocumentation() + ""; } else { - foreach (IMember baseMember in InheritanceHelper.GetBaseMembers((IMember)declaringEntity, includeImplementedInterfaces: true)) + foreach (IMember baseMember in InheritanceHelper.GetBaseMembers((IMember?)declaringEntity, includeImplementedInterfaces: true)) { inheritedDocumentation = baseMember.GetDocumentation(); if (inheritedDocumentation != null) { inheritedFrom = baseMember; + inheritedDocumentation = "" + inheritedDocumentation + ""; break; } } @@ -214,10 +215,10 @@ namespace ICSharpCode.Decompiler.Documentation if (inheritedDocumentation != null) { - var doc = XDocument.Parse(inheritedDocumentation); + var doc = XDocument.Parse(inheritedDocumentation).Element("doc"); // 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 List doNotInherit = new List();