@@ -580,7 +580,7 @@ public void DynamicExpressionParser_ParseLambda_Select_2()
580
580
581
581
// https://github.com/StefH/System.Linq.Dynamic.Core/issues/58
582
582
[ Fact ]
583
- public void DynamicExpressionParser_ParseLambda_4_Issue58 ( )
583
+ public void DynamicExpressionParser_ParseLambda_Issue58 ( )
584
584
{
585
585
var expressionParams = new [ ]
586
586
{
@@ -1251,14 +1251,16 @@ public void DynamicExpressionParser_ParseLambda_Operator_Less_Greater_With_Guids
1251
1251
}
1252
1252
1253
1253
[ Theory ]
1254
- [ InlineData ( "c => c.Age == 8" , "c => (c.Age == 8)" ) ]
1255
- [ InlineData ( "c => c.Name == \" test\" " , "c => (c.Name == \" test\" )" ) ]
1256
- public void DynamicExpressionParser_ParseLambda_RenameParameterExpression ( string expressionAsString , string expected )
1254
+ [ InlineData ( true , "c => c.Age == 8" , "c => (c.Age == 8)" ) ]
1255
+ [ InlineData ( true , "c => c.Name == \" test\" " , "c => (c.Name == \" test\" )" ) ]
1256
+ [ InlineData ( false , "c => c.Age == 8" , "Param_0 => (Param_0.Age == 8)" ) ]
1257
+ [ InlineData ( false , "c => c.Name == \" test\" " , "Param_0 => (Param_0.Name == \" test\" )" ) ]
1258
+ public void DynamicExpressionParser_ParseLambda_RenameParameterExpression ( bool renameParameterExpression , string expressionAsString , string expected )
1257
1259
{
1258
1260
// Arrange
1259
1261
var config = new ParsingConfig
1260
1262
{
1261
- RenameParameterExpression = true
1263
+ RenameParameterExpression = renameParameterExpression
1262
1264
} ;
1263
1265
1264
1266
// Act
@@ -1500,22 +1502,28 @@ public void DynamicExpressionParser_ParseLambda_Func()
1500
1502
}
1501
1503
1502
1504
[ Theory ]
1503
- [ InlineData ( 1 , true ) ]
1504
- [ InlineData ( 5 , false ) ]
1505
- public void DynamicExpressionParser_ParseLambda_Func2 ( int ? input , bool expected )
1505
+ [ InlineData ( "value" , "value != null && value == 1" , 1 , true ) ]
1506
+ [ InlineData ( "value" , "value != null && value == 1" , 5 , false ) ]
1507
+ [ InlineData ( "x" , "value != null && value == 1" , 1 , true ) ]
1508
+ [ InlineData ( "x" , "value != null && value == 1" , 5 , false ) ]
1509
+ [ InlineData ( null , "value != null && value == 1" , 1 , true ) ]
1510
+ [ InlineData ( null , "value != null && value == 1" , 5 , false ) ]
1511
+ [ InlineData ( "value" , "value => value != null && value == 1" , 1 , true ) ]
1512
+ [ InlineData ( "value" , "value => value != null && value == 1" , 5 , false ) ]
1513
+ public void DynamicExpressionParser_ParseLambda_Func2 ( string ? paramName , string test , int ? input , bool expected )
1506
1514
{
1507
1515
// Arrange
1508
1516
var nullableType = typeof ( int ? ) ;
1509
- var functionType = typeof ( Func < , > ) . MakeGenericType ( nullableType , typeof ( bool ) ) ;
1510
- var valueParameter = Expression . Parameter ( nullableType , "value" ) ;
1517
+ var delegateType = typeof ( Func < , > ) . MakeGenericType ( nullableType , typeof ( bool ) ) ;
1518
+ var valueParameter = paramName is not null ? Expression . Parameter ( nullableType , paramName ) : Expression . Parameter ( nullableType ) ;
1511
1519
1512
1520
// Act 1
1513
1521
var expression = DynamicExpressionParser . ParseLambda (
1514
- functionType ,
1522
+ delegateType ,
1515
1523
new ParsingConfig ( ) ,
1516
1524
new [ ] { valueParameter } ,
1517
1525
typeof ( bool ) ,
1518
- "value != null && value == 1"
1526
+ test
1519
1527
) ;
1520
1528
1521
1529
// Act 2
0 commit comments