@@ -20,7 +20,7 @@ public static partial class Check
2020 /// <exception cref="ArgumentNullException">Thrown when <paramref name="parameter" /> is null.</exception>
2121 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
2222 [ ContractAnnotation ( "parameter:null => halt; parameter:notnull => notnull" ) ]
23- public static T MustNotBeNull < T > ( [ ValidatedNotNull ] this T ? parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null ) where T : class
23+ public static T MustNotBeNull < T > ( [ ValidatedNotNull , NoEnumeration ] this T ? parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null ) where T : class
2424 {
2525 if ( parameter is null )
2626 Throw . ArgumentNull ( parameterName , message ) ;
@@ -35,7 +35,7 @@ public static T MustNotBeNull<T>([ValidatedNotNull] this T? parameter, [CallerAr
3535 /// <exception cref="Exception">Your custom exception thrown when <paramref name="parameter" /> is null.</exception>
3636 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
3737 [ ContractAnnotation ( "parameter:null => halt; parameter:notnull => notnull; exceptionFactory:null => halt" ) ]
38- public static T MustNotBeNull < T > ( [ ValidatedNotNull ] this T ? parameter , Func < Exception > exceptionFactory ) where T : class
38+ public static T MustNotBeNull < T > ( [ ValidatedNotNull , NoEnumeration ] this T ? parameter , Func < Exception > exceptionFactory ) where T : class
3939 {
4040 if ( parameter is null )
4141 Throw . CustomException ( exceptionFactory ) ;
@@ -101,7 +101,7 @@ public static T MustNotBeDefault<T>([ValidatedNotNull] this T parameter, Func<Ex
101101 /// <exception cref="ArgumentNullException">Thrown when <typeparamref name="T" /> is a reference type and <paramref name="parameter" /> is null.</exception>
102102 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
103103 [ ContractAnnotation ( "parameter:null => halt; parameter:notnull => notnull" ) ]
104- public static T MustNotBeNullReference < T > ( [ ValidatedNotNull ] this T parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null )
104+ public static T MustNotBeNullReference < T > ( [ ValidatedNotNull , NoEnumeration ] this T parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null )
105105 {
106106 if ( default ( T ) != null )
107107 return parameter ;
@@ -121,7 +121,7 @@ public static T MustNotBeNullReference<T>([ValidatedNotNull] this T parameter, [
121121 /// <exception cref="Exception">Your custom exception thrown when <typeparamref name="T" /> is a reference type and <paramref name="parameter" /> is null.</exception>
122122 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
123123 [ ContractAnnotation ( "parameter:null => halt; parameter:notnull => notnull; exceptionFactory:null => halt" ) ]
124- public static T MustNotBeNullReference < T > ( [ ValidatedNotNull ] this T parameter , Func < Exception > exceptionFactory )
124+ public static T MustNotBeNullReference < T > ( [ ValidatedNotNull , NoEnumeration ] this T parameter , Func < Exception > exceptionFactory )
125125 {
126126 if ( default ( T ) != null )
127127 return parameter ;
@@ -141,7 +141,7 @@ public static T MustNotBeNullReference<T>([ValidatedNotNull] this T parameter, F
141141 /// <exception cref="ArgumentNullException">Thrown when <paramref name="parameter" /> is null.</exception>
142142 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
143143 [ ContractAnnotation ( "parameter:null => halt; parameter:notnull => notnull" ) ]
144- public static T MustBeOfType < T > ( [ ValidatedNotNull ] this object ? parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null )
144+ public static T MustBeOfType < T > ( [ ValidatedNotNull , NoEnumeration ] this object ? parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null )
145145 {
146146 if ( parameter . MustNotBeNull ( parameterName , message ) is T castValue )
147147 return castValue ;
@@ -158,7 +158,7 @@ public static T MustBeOfType<T>([ValidatedNotNull] this object? parameter, [Call
158158 /// <exception cref="Exception">Your custom exception thrown when <paramref name="parameter" /> cannot be cast to <typeparamref name="T" />.</exception>
159159 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
160160 [ ContractAnnotation ( "parameter:null => halt; parameter:notnull => notnull; exceptionFactory:null => halt" ) ]
161- public static T MustBeOfType < T > ( [ ValidatedNotNull ] this object ? parameter , Func < object ? , Exception > exceptionFactory )
161+ public static T MustBeOfType < T > ( [ ValidatedNotNull , NoEnumeration ] this object ? parameter , Func < object ? , Exception > exceptionFactory )
162162 {
163163 if ( parameter is T castValue )
164164 return castValue ;
@@ -328,7 +328,7 @@ public static void InvalidArgument<T>(bool condition, T parameter, Func<T, Excep
328328 /// <param name="message">The message that will be passed to the resulting exception (optional).</param>
329329 /// <exception cref="NullableHasNoValueException">Thrown when <paramref name="parameter" /> has no value.</exception>
330330 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
331- public static T MustHaveValue < T > ( this T ? parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null ) where T : struct
331+ public static T MustHaveValue < T > ( [ NoEnumeration ] this T ? parameter , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null ) where T : struct
332332 {
333333 if ( ! parameter . HasValue )
334334 Throw . NullableHasNoValue ( parameterName , message ) ;
@@ -344,7 +344,7 @@ public static T MustHaveValue<T>(this T? parameter, [CallerArgumentExpression("p
344344 /// <exception cref="NullableHasNoValueException">Thrown when <paramref name="parameter" /> has no value.</exception>
345345 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
346346 [ ContractAnnotation ( "exceptionFactory:null => halt" ) ]
347- public static T MustHaveValue < T > ( this T ? parameter , Func < Exception > exceptionFactory ) where T : struct
347+ public static T MustHaveValue < T > ( [ NoEnumeration ] this T ? parameter , Func < Exception > exceptionFactory ) where T : struct
348348 {
349349 if ( ! parameter . HasValue )
350350 Throw . CustomException ( exceptionFactory ) ;
@@ -359,7 +359,7 @@ public static T MustHaveValue<T>(this T? parameter, Func<Exception> exceptionFac
359359 // ReSharper disable StringLiteralTypo
360360 [ ContractAnnotation ( "parameter:notNull => true, other:notnull; parameter:notNull => false, other:canbenull; other:notnull => true, parameter:notnull; other:notnull => false, parameter:canbenull" ) ]
361361 // ReSharper restore StringLiteralTypo
362- public static bool IsSameAs < T > ( this T ? parameter , T ? other ) where T : class =>
362+ public static bool IsSameAs < T > ( [ NoEnumeration ] this T ? parameter , [ NoEnumeration ] T ? other ) where T : class =>
363363 ReferenceEquals ( parameter , other ) ;
364364
365365 /// <summary>
@@ -372,7 +372,7 @@ public static bool IsSameAs<T>(this T? parameter, T? other) where T : class =>
372372 /// <param name="message">The message that will be passed to the resulting exception (optional).</param>
373373 /// <exception cref="SameObjectReferenceException">Thrown when both <paramref name="parameter" /> and <paramref name="other" /> point to the same object.</exception>
374374 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
375- public static T ? MustNotBeSameAs < T > ( this T ? parameter , T ? other , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null ) where T : class
375+ public static T ? MustNotBeSameAs < T > ( [ NoEnumeration ] this T ? parameter , [ NoEnumeration ] T ? other , [ CallerArgumentExpression ( "parameter" ) ] string ? parameterName = null , string ? message = null ) where T : class
376376 {
377377 if ( ReferenceEquals ( parameter , other ) )
378378 Throw . SameObjectReference ( parameter , parameterName , message ) ;
@@ -388,7 +388,7 @@ public static bool IsSameAs<T>(this T? parameter, T? other) where T : class =>
388388 /// <param name="exceptionFactory">The delegate that creates your custom exception. <paramref name="parameter" /> is passed to this delegate.</param>
389389 /// <exception cref="SameObjectReferenceException">Thrown when both <paramref name="parameter" /> and <paramref name="other" /> point to the same object.</exception>
390390 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
391- public static T ? MustNotBeSameAs < T > ( this T ? parameter , T ? other , Func < T ? , Exception > exceptionFactory ) where T : class
391+ public static T ? MustNotBeSameAs < T > ( [ NoEnumeration ] this T ? parameter , T ? other , Func < T ? , Exception > exceptionFactory ) where T : class
392392 {
393393 if ( ReferenceEquals ( parameter , other ) )
394394 Throw . CustomException ( exceptionFactory , parameter ) ;
0 commit comments