4
4
using System ;
5
5
using System . Collections . Generic ;
6
6
using System . Diagnostics ;
7
+ using System . Diagnostics . CodeAnalysis ;
7
8
using System . Globalization ;
8
9
using System . Linq ;
9
10
using System . Linq . Expressions ;
@@ -64,7 +65,11 @@ internal static TDelegate CompileUsingExpressionCompiler<TDelegate>(this Express
64
65
return ExpressionCompiler . Instance . Compile ( expression ) ;
65
66
}
66
67
67
- public static bool IsMatch ( this Expression expression , out Match match )
68
+ #if NULLABLE_REFERENCE_TYPES
69
+ public static bool IsMatch ( this Expression expression , [ NotNullWhen ( true ) ] out Match ? match )
70
+ #else
71
+ public static bool IsMatch ( this Expression expression , out Match ? match )
72
+ #endif
68
73
{
69
74
if ( expression is MatchExpression matchExpression )
70
75
{
@@ -262,6 +267,7 @@ void Split(Expression e, out Expression r /* remainder */, out MethodExpectation
262
267
}
263
268
else // This should be unreachable.
264
269
{
270
+ // TODO: Should we throw here?
265
271
method = null ;
266
272
}
267
273
p = new MethodExpectation (
@@ -286,7 +292,7 @@ void Split(Expression e, out Expression r /* remainder */, out MethodExpectation
286
292
expression : Expression . Lambda (
287
293
Expression . Invoke ( parameter , arguments ) ,
288
294
parameter ) ,
289
- method : r . Type . GetMethod ( "Invoke" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) ,
295
+ method : r . Type . GetMethod ( "Invoke" , BindingFlags . Public | BindingFlags . NonPublic | BindingFlags . Instance ) ! ,
290
296
arguments ) ;
291
297
return ;
292
298
}
@@ -321,7 +327,8 @@ void Split(Expression e, out Expression r /* remainder */, out MethodExpectation
321
327
}
322
328
else // This should be unreachable.
323
329
{
324
- method = null ;
330
+ // TODO: Should we throw here?
331
+ method = null ! ;
325
332
}
326
333
p = new MethodExpectation (
327
334
expression : Expression . Lambda (
@@ -341,7 +348,7 @@ void Split(Expression e, out Expression r /* remainder */, out MethodExpectation
341
348
342
349
bool IsResult ( MemberInfo member , out IAwaitableFactory ? awaitableFactory )
343
350
{
344
- var instanceType = member . DeclaringType ;
351
+ var instanceType = member . DeclaringType ! ;
345
352
awaitableFactory = AwaitableFactory . TryGet ( instanceType ) ;
346
353
var returnType = member switch
347
354
{
@@ -363,7 +370,7 @@ internal static PropertyInfo GetReboundProperty(this MemberExpression expression
363
370
// the expression. we attempt to correct this here by checking whether the type of the accessed object
364
371
// has a property by the same name whose base definition equals the property in the expression; if so,
365
372
// we "upgrade" to the derived property.
366
- if ( property . DeclaringType != expression . Expression . Type )
373
+ if ( property . DeclaringType != expression . Expression ! . Type )
367
374
{
368
375
var parameterTypes = new ParameterTypes ( property . GetIndexParameters ( ) ) ;
369
376
var derivedProperty = expression . Expression . Type
0 commit comments