File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
ReadableExpressions.UnitTests Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,20 @@ public void ShouldTranslateQuotedLambdaWithAnAnnotation()
140140 translated . ShouldBe ( EXPECTED ) ;
141141 }
142142
143+ // See https://github.com/agileobjects/ReadableExpressions/issues/31
144+ [ Fact ]
145+ public void ShouldTranslateUnnamedLambdaParameters ( )
146+ {
147+ var stringsParameter = Expression . Parameter ( typeof ( string [ ] ) ) ;
148+ var linqSelect = CreateLambda ( ( string [ ] ints ) => ints . Select ( int . Parse ) ) ;
149+ var linqSelectWithUnnamed = Expression . Lambda ( linqSelect . Body , stringsParameter ) ;
150+ var quoted = Expression . Quote ( linqSelectWithUnnamed ) ;
151+
152+ var translated = ToReadableString ( quoted ) ;
153+
154+ translated . ShouldBe ( "stringArray => ints.Select(int.Parse)" ) ;
155+ }
156+
143157 [ Fact ]
144158 public void ShouldTranslateRuntimeVariables ( )
145159 {
Original file line number Diff line number Diff line change @@ -196,8 +196,8 @@ private void Visit(Expression expression)
196196 continue ;
197197
198198 case ExpressionType . Lambda :
199- expression = ( ( LambdaExpression ) expression ) . Body ;
200- continue ;
199+ Visit ( ( LambdaExpression ) expression ) ;
200+ return ;
201201
202202 case ExpressionType . ListInit :
203203 Visit ( ( ListInitExpression ) expression ) ;
@@ -381,6 +381,12 @@ private void Visit(InvocationExpression invocation)
381381 Visit ( invocation . Expression ) ;
382382 }
383383
384+ private void Visit ( LambdaExpression lambda )
385+ {
386+ Visit ( lambda . Parameters ) ;
387+ Visit ( lambda . Body ) ;
388+ }
389+
384390 private void Visit ( ListInitExpression init )
385391 {
386392 Visit ( init . NewExpression ) ;
You can’t perform that action at this time.
0 commit comments