1
0
mirror of https://github.com/chylex/.NET-Community-Toolkit.git synced 2025-04-10 11:15:45 +02:00

Remove class constraint from Guaard.Is[Not]Null APIs

This commit is contained in:
Sergio Pedri 2021-12-31 19:48:24 +01:00
parent 87268d40b6
commit 5d7f2a7674
2 changed files with 1 additions and 4 deletions
CommunityToolkit.Diagnostics

View File

@ -24,7 +24,6 @@ public static partial class Guard
/// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is not <see langword="null"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNull<T>(T? value, [CallerArgumentExpression("value")] string name = "")
where T : class
{
if (value is null)
{
@ -63,7 +62,6 @@ public static void IsNull<T>(T? value, [CallerArgumentExpression("value")] strin
/// <exception cref="ArgumentNullException">Thrown if <paramref name="value"/> is <see langword="null"/>.</exception>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void IsNotNull<T>([NotNull] T? value, [CallerArgumentExpression("value")] string name = "")
where T : class
{
if (value is not null)
{

View File

@ -38,9 +38,8 @@ private static string AssertString(object? obj)
/// <typeparam name="T">The type of the input value.</typeparam>
[DoesNotReturn]
public static void ThrowArgumentExceptionForIsNull<T>(T value, string name)
where T : class
{
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(T).ToTypeString()}) must be null, was {AssertString(value)} ({value.GetType().ToTypeString()}).", name);
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(T).ToTypeString()}) must be null, was {AssertString(value)} ({value!.GetType().ToTypeString()}).", name);
}
/// <summary>