Share via


Requires.NotNull Method

Definition

Overloads

NotNull(IntPtr, String)

Throws an exception if the specified parameter's value is IntPtr.Zero.

NotNull(Task, String)

Throws an exception if the specified parameter's value is null.

NotNull<T>(Task<T>, String)

Throws an exception if the specified parameter's value is null.

NotNull<T>(T, String)

Throws an exception if the specified parameter's value is null.

NotNull(IntPtr, String)

Throws an exception if the specified parameter's value is IntPtr.Zero.

public:
 static IntPtr NotNull(IntPtr value, System::String ^ parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static IntPtr NotNull (IntPtr value, string? parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static IntPtr NotNull (IntPtr value, string? parameterName = default);
[<System.Diagnostics.DebuggerStepThrough>]
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")>]
static member NotNull : nativeint * string -> nativeint
Public Shared Function NotNull (value As IntPtr, parameterName As String) As IntPtr
Public Shared Function NotNull (value As IntPtr, Optional parameterName As String = Nothing) As IntPtr

Parameters

value
IntPtr

nativeint

The value of the argument.

parameterName
String

The name of the parameter to include in any thrown exception. If this argument is omitted (explicitly writing null does not qualify), the expression used in the first argument will be used as the parameter name.

Returns

IntPtr

nativeint

The value of the parameter.

Attributes

Exceptions

Thrown if value is Zero.

Applies to

NotNull(Task, String)

Throws an exception if the specified parameter's value is null.

public:
 static void NotNull(System::Threading::Tasks::Task ^ value, System::String ^ parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static void NotNull (System.Threading.Tasks.Task value, string? parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static void NotNull (System.Threading.Tasks.Task value, string? parameterName = default);
[<System.Diagnostics.DebuggerStepThrough>]
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")>]
static member NotNull : System.Threading.Tasks.Task * string -> unit
Public Shared Sub NotNull (value As Task, parameterName As String)
Public Shared Sub NotNull (value As Task, Optional parameterName As String = Nothing)

Parameters

value
Task

The value of the argument.

parameterName
String

The name of the parameter to include in any thrown exception. If this argument is omitted (explicitly writing null does not qualify), the expression used in the first argument will be used as the parameter name.

Attributes

Exceptions

Thrown if value is null.

Remarks

This method allows async methods to use Requires.NotNull without having to assign the result to local variables to avoid C# warnings.

Applies to

NotNull<T>(Task<T>, String)

Throws an exception if the specified parameter's value is null.

public:
generic <typename T>
 static void NotNull(System::Threading::Tasks::Task<T> ^ value, System::String ^ parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static void NotNull<T> (System.Threading.Tasks.Task<T> value, string? parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static void NotNull<T> (System.Threading.Tasks.Task<T> value, string? parameterName = default);
[<System.Diagnostics.DebuggerStepThrough>]
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")>]
static member NotNull : System.Threading.Tasks.Task<'T> * string -> unit
Public Shared Sub NotNull(Of T) (value As Task(Of T), parameterName As String)
Public Shared Sub NotNull(Of T) (value As Task(Of T), Optional parameterName As String = Nothing)

Type Parameters

T

The type of the return value of the task.

Parameters

value
Task<T>

The value of the argument.

parameterName
String

The name of the parameter to include in any thrown exception. If this argument is omitted (explicitly writing null does not qualify), the expression used in the first argument will be used as the parameter name.

Attributes

Exceptions

Thrown if value is null.

Remarks

This method allows async methods to use Requires.NotNull without having to assign the result to local variables to avoid C# warnings.

Applies to

NotNull<T>(T, String)

Throws an exception if the specified parameter's value is null.

public:
generic <typename T>
 where T : class static T NotNull(T value, System::String ^ parameterName);
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static T NotNull<T> (T value, string? parameterName) where T : class;
[System.Diagnostics.DebuggerStepThrough]
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static T NotNull<T> (T value, string? parameterName = default) where T : class;
[<System.Diagnostics.DebuggerStepThrough>]
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")>]
static member NotNull : 'T * string -> 'T (requires 'T : null)
Public Shared Function NotNull(Of T As Class) (value As T, parameterName As String) As T
Public Shared Function NotNull(Of T As Class) (value As T, Optional parameterName As String = Nothing) As T

Type Parameters

T

The type of the parameter.

Parameters

value
T

The value of the argument.

parameterName
String

The name of the parameter to include in any thrown exception. If this argument is omitted (explicitly writing null does not qualify), the expression used in the first argument will be used as the parameter name.

Returns

T

The value of the parameter.

Attributes

Exceptions

Thrown if value is null.

Applies to