Browse Source

Fix nullability warnings in AstNode and XmlDocumentationElement.

pull/2639/head
Siegfried Pammer 3 years ago
parent
commit
2e31427d56
  1. 4
      ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs
  2. 4
      ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs

4
ICSharpCode.Decompiler/CSharp/Syntax/AstNode.cs

@ -358,9 +358,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax @@ -358,9 +358,9 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax
return Ancestors.OfType<T>().FirstOrDefault();
}
public AstNode GetParent(Func<AstNode, bool>? pred)
public AstNode? GetParent(Func<AstNode, bool>? pred)
{
return Ancestors.FirstOrDefault(pred);
return pred != null ? Ancestors.FirstOrDefault(pred) : Ancestors.FirstOrDefault();
}
public AstNodeCollection<T> GetChildrenByRole<T>(Role<T> role) where T : AstNode

4
ICSharpCode.Decompiler/Documentation/XmlDocumentationElement.cs

@ -118,7 +118,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -118,7 +118,7 @@ namespace ICSharpCode.Decompiler.Documentation
/// </summary>
public string? GetAttribute(string? name)
{
return element?.Attribute(name)?.Value;
return name == null ? null : element?.Attribute(name)?.Value;
}
/// <summary>
@ -212,7 +212,7 @@ namespace ICSharpCode.Decompiler.Documentation @@ -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<string> doNotInherit = new List<string>();

Loading…
Cancel
Save