diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs b/ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs index 2b9eeac08..d909c26e8 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/AstNodeCollection.cs @@ -294,22 +294,22 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax /// Returns the first element for which the predicate returns true, /// or null if no such object is found. /// - public T FirstOrNull(Func? predicate = null) + public T? FirstOrNull(Func? predicate = null) { if (list != null) foreach (T item in list) if (predicate == null || predicate(item)) return item; - return null!; + return null; } /// /// Returns the last element for which the predicate returns true, /// or null if no such object is found. /// - public T LastOrNull(Func? predicate = null) + public T? LastOrNull(Func? predicate = null) { - T result = null!; + T? result = null; if (list != null) foreach (T item in list) if (predicate == null || predicate(item)) diff --git a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/VariableDeclarationStatement.cs b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/VariableDeclarationStatement.cs index f1ac343e1..8d1425180 100644 --- a/ICSharpCode.Decompiler/CSharp/Syntax/Statements/VariableDeclarationStatement.cs +++ b/ICSharpCode.Decompiler/CSharp/Syntax/Statements/VariableDeclarationStatement.cs @@ -48,7 +48,7 @@ namespace ICSharpCode.Decompiler.CSharp.Syntax [Slot("Variable")] public partial AstNodeCollection Variables { get; } - public VariableInitializer GetVariable(string name) + public VariableInitializer? GetVariable(string name) { return Variables.FirstOrNull(vi => vi.Name == name); }