3
3
4
4
using System ;
5
5
using System . Collections . Generic ;
6
+ using System . Diagnostics . CodeAnalysis ;
6
7
using System . Globalization ;
7
8
using System . Linq ;
8
9
using System . Linq . Expressions ;
@@ -51,7 +52,7 @@ public ISetup<T> Setup(string methodName, Type[] genericTypeArguments, bool exac
51
52
return this . InternalSetup ( methodName , genericTypeArguments , exactParameterMatch , args ) ;
52
53
}
53
54
54
- ISetup < T > InternalSetup ( string methodName , Type [ ] genericTypeArguments , bool exactParameterMatch , params object [ ] args )
55
+ ISetup < T > InternalSetup ( string methodName , Type [ ] ? genericTypeArguments , bool exactParameterMatch , params object [ ] args )
55
56
{
56
57
Guard . NotNull ( methodName , nameof ( methodName ) ) ;
57
58
@@ -80,7 +81,7 @@ public ISetup<T, TResult> Setup<TResult>(string methodName, Type[] genericTypeAr
80
81
return this . InternalSetup < TResult > ( methodName , genericTypeArguments , exactParameterMatch , args ) ;
81
82
}
82
83
83
- ISetup < T , TResult > InternalSetup < TResult > ( string methodName , Type [ ] genericTypeArguments ,
84
+ ISetup < T , TResult > InternalSetup < TResult > ( string methodName , Type [ ] ? genericTypeArguments ,
84
85
bool exactParameterMatch , params object [ ] args )
85
86
{
86
87
Guard . NotNullOrEmpty ( methodName , nameof ( methodName ) ) ;
@@ -147,7 +148,7 @@ public ISetupSequentialAction SetupSequence(string methodOrPropertyName, Type[]
147
148
return this . InternalSetupSequence ( methodOrPropertyName , genericTypeArguments , exactParameterMatch , args ) ;
148
149
}
149
150
150
- ISetupSequentialAction InternalSetupSequence ( string methodOrPropertyName , Type [ ] genericTypeArguments , bool exactParameterMatch , params object [ ] args )
151
+ ISetupSequentialAction InternalSetupSequence ( string methodOrPropertyName , Type [ ] ? genericTypeArguments , bool exactParameterMatch , params object [ ] args )
151
152
{
152
153
Guard . NotNullOrEmpty ( methodOrPropertyName , nameof ( methodOrPropertyName ) ) ;
153
154
@@ -175,7 +176,7 @@ public ISetupSequentialResult<TResult> SetupSequence<TResult>(string methodOrPro
175
176
return this . InternalSetupSequence < TResult > ( methodOrPropertyName , genericTypeArguments , exactParameterMatch , args ) ;
176
177
}
177
178
178
- ISetupSequentialResult < TResult > InternalSetupSequence < TResult > ( string methodOrPropertyName , Type [ ] genericTypeArguments , bool exactParameterMatch , params object [ ] args )
179
+ ISetupSequentialResult < TResult > InternalSetupSequence < TResult > ( string methodOrPropertyName , Type [ ] ? genericTypeArguments , bool exactParameterMatch , params object [ ] args )
179
180
{
180
181
Guard . NotNullOrEmpty ( methodOrPropertyName , nameof ( methodOrPropertyName ) ) ;
181
182
@@ -223,7 +224,7 @@ public void Verify(string methodName, Type[] genericTypeArguments, Times times,
223
224
this . InternalVerify ( methodName , genericTypeArguments , times , exactParameterMatch , args ) ;
224
225
}
225
226
226
- void InternalVerify ( string methodName , Type [ ] genericTypeArguments , Times times , bool exactParameterMatch , params object [ ] args )
227
+ void InternalVerify ( string methodName , Type [ ] ? genericTypeArguments , Times times , bool exactParameterMatch , params object [ ] args )
227
228
{
228
229
Guard . NotNullOrEmpty ( methodName , nameof ( methodName ) ) ;
229
230
@@ -256,7 +257,7 @@ public void Verify<TResult>(string methodName, Type[] genericTypeArguments, Time
256
257
this . InternalVerify < TResult > ( methodName , genericTypeArguments , times , exactParameterMatch , args ) ;
257
258
}
258
259
259
- void InternalVerify < TResult > ( string methodName , Type [ ] genericTypeArguments , Times times , bool exactParameterMatch , params object [ ] args )
260
+ void InternalVerify < TResult > ( string methodName , Type [ ] ? genericTypeArguments , Times times , bool exactParameterMatch , params object [ ] args )
260
261
{
261
262
Guard . NotNullOrEmpty ( methodName , nameof ( methodName ) ) ;
262
263
@@ -359,7 +360,11 @@ static Expression<Action<T>> GetSetterExpression(PropertyInfo property, Expressi
359
360
param ) ;
360
361
}
361
362
362
- static void ThrowIfMemberMissing ( string memberName , MemberInfo member )
363
+ #if NULLABLE_REFERENCE_TYPES
364
+ static void ThrowIfMemberMissing ( string memberName , [ NotNull ] MemberInfo ? member )
365
+ #else
366
+ static void ThrowIfMemberMissing ( string memberName , MemberInfo ? member )
367
+ #endif
363
368
{
364
369
if ( member == null )
365
370
{
@@ -371,7 +376,11 @@ static void ThrowIfMemberMissing(string memberName, MemberInfo member)
371
376
}
372
377
}
373
378
374
- static void ThrowIfMethodMissing ( string methodName , MethodInfo method , object [ ] args )
379
+ #if NULLABLE_REFERENCE_TYPES
380
+ static void ThrowIfMethodMissing ( string methodName , [ NotNull ] MethodInfo ? method , object [ ] args )
381
+ #else
382
+ static void ThrowIfMethodMissing ( string methodName , MethodInfo ? method , object [ ] args )
383
+ #endif
375
384
{
376
385
if ( method == null )
377
386
{
@@ -443,14 +452,14 @@ static void ThrowIfVoidMethod(MethodInfo method)
443
452
}
444
453
}
445
454
446
- static Type [ ] ToArgTypes ( object [ ] args )
455
+ static Type ? [ ] ToArgTypes ( object [ ] args )
447
456
{
448
457
if ( args == null )
449
458
{
450
459
throw new ArgumentException ( Resources . UseItExprIsNullRatherThanNullArgumentValue ) ;
451
460
}
452
461
453
- var types = new Type [ args . Length ] ;
462
+ var types = new Type ? [ args . Length ] ;
454
463
for ( int index = 0 ; index < args . Length ; index ++ )
455
464
{
456
465
if ( args [ index ] == null )
@@ -503,9 +512,9 @@ static bool IsItRefAny(Expression expression)
503
512
return ItRefAnyField ( expression ) != null ;
504
513
}
505
514
506
- static FieldInfo ItRefAnyField ( Expression expr )
515
+ static FieldInfo ? ItRefAnyField ( Expression expr )
507
516
{
508
- FieldInfo itRefAnyField = null ;
517
+ FieldInfo ? itRefAnyField = null ;
509
518
510
519
if ( expr . NodeType == ExpressionType . MemberAccess )
511
520
{
@@ -514,7 +523,7 @@ static FieldInfo ItRefAnyField(Expression expr)
514
523
{
515
524
if ( field . Name == nameof ( It . Ref < object > . IsAny ) )
516
525
{
517
- var fieldDeclaringType = field . DeclaringType ;
526
+ var fieldDeclaringType = field . DeclaringType ! ;
518
527
if ( fieldDeclaringType . IsGenericType )
519
528
{
520
529
var fieldDeclaringTypeDefinition = fieldDeclaringType . GetGenericTypeDefinition ( ) ;
0 commit comments