Guard
Class used to guard against unexpected argument values
or operations by throwing an appropriate exception.
using NUnit.Framework.Internal;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace NUnit.Framework
{
[NullableContext(1)]
[Nullable(0)]
internal static class Guard
{
public static void ArgumentNotNull([Nullable(2)] [NotNull] object value, string name)
{
if (value == null)
<ArgumentNotNull>g__ThrowArgumentNullException|0_0(name);
}
public static void ArgumentNotNullOrEmpty([Nullable(2)] [NotNull] string value, string name)
{
ArgumentNotNull(value, name);
if (value == string.Empty)
<ArgumentNotNullOrEmpty>g__ThrowArgumentNotNullOrEmpty|1_0(name);
}
public static void ArgumentInRange([DoesNotReturnIf(false)] bool condition, string message, string paramName)
{
if (!condition)
<ArgumentInRange>g__ThrowArgumentOutOfRangeException|2_0(message, paramName);
}
public static void ArgumentValid([DoesNotReturnIf(false)] bool condition, string message, string paramName)
{
if (!condition)
<ArgumentValid>g__ThrowArgumentException|3_0(message, paramName);
}
public static void OperationValid([DoesNotReturnIf(false)] bool condition, string message)
{
if (!condition)
<OperationValid>g__ThrowInvalidOperationException|4_0(message);
}
public static void ArgumentNotAsyncVoid(Delegate delegate, string paramName)
{
ArgumentNotAsyncVoid(delegate.GetMethodInfo(), paramName);
}
public static void ArgumentNotAsyncVoid(MethodInfo method, string paramName)
{
if (!(method.ReturnType != typeof(void)) && AsyncToSyncAdapter.IsAsyncOperation(method))
<ArgumentNotAsyncVoid>g__ThrowArgumentNotAsyncVoid|6_0(paramName);
}
}
}