Open sandboxFocus

Method AssertNotNull

AssertNotNull<T>(T?, string?)

Checks that a reference is non-null and throws an AssertionFailedException if it is not.

Declaration
public static T AssertNotNull<T>(this T? obj, string? description = null) where T : class
Parameters
Type Name Description
T obj
string description
Returns
Type Description
T
Type Parameters
Name Description
T

AssertNotNull<T>(Task<T?>?, string?)

Declaration
[Obsolete("Use AssertNotNullAsync")]
public static Task<T> AssertNotNull<T>(this Task<T?>? task, string? description = null) where T : class
Parameters
Type Name Description
Task<T> task
string description
Returns
Type Description
Task<T>
Type Parameters
Name Description
T

AssertNotNull<T>(ValueTask<T?>, string?)

Declaration
[Obsolete("Use AssertNotNullAsync")]
public static ValueTask<T> AssertNotNull<T>(this ValueTask<T?> task, string? description = null) where T : class
Parameters
Type Name Description
ValueTask<T> task
string description
Returns
Type Description
ValueTask<T>
Type Parameters
Name Description
T

AssertNotNull<T>(T?, string?)

Checks that a nullable value is non-null and throws an AssertionFailedException if it is not.

Declaration
public static T AssertNotNull<T>(this T? obj, string? description = null) where T : struct
Parameters
Type Name Description
T? obj
string description
Returns
Type Description
T
Type Parameters
Name Description
T