Skip to content

Commit

Permalink
Annotate return value for consumers
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed May 27, 2022
1 parent 2233327 commit 1f72704
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions osu.Framework/Extensions/ObjectExtensions/ObjectExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#nullable enable

using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace osu.Framework.Extensions.ObjectExtensions
{
Expand Down Expand Up @@ -31,11 +32,11 @@ public static T AsNonNull<T>(this T? obj)
/// <summary>
/// If the given object is null.
/// </summary>
public static bool IsNull<T>(this T obj) => ReferenceEquals(obj, null);
public static bool IsNull<T>([NotNullWhen(false)] this T obj) => ReferenceEquals(obj, null);

/// <summary>
/// <c>true</c> if the given object is not null, <c>false</c> otherwise.
/// </summary>
public static bool IsNotNull<T>(this T obj) => !ReferenceEquals(obj, null);
public static bool IsNotNull<T>([NotNullWhen(true)] this T obj) => !ReferenceEquals(obj, null);
}
}

0 comments on commit 1f72704

Please sign in to comment.