diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs b/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs index b23183c6d..b11edf399 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs @@ -358,9 +358,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax return Ancestors.OfType().FirstOrDefault(); } - public AstNode GetParent(Func? pred) + public AstNode? GetParent(Func? pred) { - return Ancestors.FirstOrDefault(pred); + return pred != null ? Ancestors.FirstOrDefault(pred) : Ancestors.FirstOrDefault(); } public AstNodeCollection GetChildrenByRole(Role role) where T : AstNode diff --git a/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs b/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs index 088f6808b..e47161764 100644 --- a/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs +++ b/ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs @@ -118,7 +118,7 @@ namespace ICSharpCode.Decompiler.Documentation /// public string? GetAttribute(string? name) { - return element?.Attribute(name)?.Value; + return name == null ? null : element?.Attribute(name)?.Value; } /// @@ -212,7 +212,7 @@ namespace ICSharpCode.Decompiler.Documentation var doc = XDocument.Parse(inheritedDocumentation).Element("doc"); // XPath filter not yet implemented - if (childElement.Parent?.Parent == null && childElement.Attribute("select")?.Value == null) + if (doc != null && childElement.Parent?.Parent == null && childElement.Attribute("select")?.Value == null) { // Inheriting documentation at the root level List doNotInherit = new List();