Skip to content

Commit 5d7f2a7

Browse files
committed
Remove class constraint from Guaard.Is[Not]Null APIs
1 parent 87268d4 commit 5d7f2a7

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

CommunityToolkit.Diagnostics/Guard.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public static partial class Guard
2424
/// <exception cref="ArgumentException">Thrown if <paramref name="value"/> is not <see langword="null"/>.</exception>
2525
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2626
public static void IsNull<T>(T? value, [CallerArgumentExpression("value")] string name = "")
27-
where T : class
2827
{
2928
if (value is null)
3029
{
@@ -63,7 +62,6 @@ public static void IsNull<T>(T? value, [CallerArgumentExpression("value")] strin
6362
/// <exception cref="ArgumentNullException">Thrown if <paramref name="value"/> is <see langword="null"/>.</exception>
6463
[MethodImpl(MethodImplOptions.AggressiveInlining)]
6564
public static void IsNotNull<T>([NotNull] T? value, [CallerArgumentExpression("value")] string name = "")
66-
where T : class
6765
{
6866
if (value is not null)
6967
{

CommunityToolkit.Diagnostics/Internals/Guard.ThrowHelper.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,8 @@ private static string AssertString(object? obj)
3838
/// <typeparam name="T">The type of the input value.</typeparam>
3939
[DoesNotReturn]
4040
public static void ThrowArgumentExceptionForIsNull<T>(T value, string name)
41-
where T : class
4241
{
43-
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(T).ToTypeString()}) must be null, was {AssertString(value)} ({value.GetType().ToTypeString()}).", name);
42+
throw new ArgumentException($"Parameter {AssertString(name)} ({typeof(T).ToTypeString()}) must be null, was {AssertString(value)} ({value!.GetType().ToTypeString()}).", name);
4443
}
4544

4645
/// <summary>

0 commit comments

Comments
 (0)