Skip to content

Commit 0fd5847

Browse files
committed
Consistently converting Quoted linq expressions
1 parent dc845b9 commit 0fd5847

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

ReadableExpressions.Visualizers.Core/CommonVisualizerAssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
[assembly: AssemblyTitle("AgileObjects.ReadableExpressions.Visualizers")]
66
[assembly: AssemblyCompany("AgileObjects")]
77
[assembly: AssemblyProduct("ReadableExpressions.Visualizers")]
8-
[assembly: AssemblyCopyright("Copyright © 2016")]
8+
[assembly: AssemblyCopyright("Copyright © 2018")]
99
[assembly: NeutralResourcesLanguage("en")]
1010
[assembly: CLSCompliant(true)]

ReadableExpressions/Translators/LinqExpressionToDlrExpressionConverter.cs

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ namespace AgileObjects.ReadableExpressions.Translators
33
{
44
using System;
55
using System.Collections.Generic;
6-
using System.Linq;
76
using System.Reflection;
87
using Extensions;
98
using Microsoft.Scripting.Ast;
@@ -195,7 +194,7 @@ private Expression Convert(LinqExp.InvocationExpression linqInvoke)
195194
{
196195
return Expression.Invoke(
197196
ConvertExp(linqInvoke.Expression),
198-
linqInvoke.Arguments.Project(ConvertExp));
197+
Convert(linqInvoke.Arguments));
199198
}
200199

201200
private Expression Convert(LinqExp.TypeBinaryExpression linqTypeBinary)
@@ -213,25 +212,25 @@ private NewExpression Convert(LinqExp.NewExpression linqNew)
213212
return (linqNew.Members != null)
214213
? Expression.New(
215214
linqNew.Constructor,
216-
linqNew.Arguments.Project(ConvertExp),
215+
Convert(linqNew.Arguments),
217216
linqNew.Members)
218217
: Expression.New(
219218
linqNew.Constructor,
220-
linqNew.Arguments.Project(ConvertExp));
219+
Convert(linqNew.Arguments));
221220
}
222221

223222
private ElementInit Convert(LinqExp.ElementInit linqElementInit)
224223
{
225224
return Expression.ElementInit(
226225
linqElementInit.AddMethod,
227-
linqElementInit.Arguments.Project(ConvertExp));
226+
Convert(linqElementInit.Arguments));
228227
}
229228

230229
private Expression Convert(LinqExp.NewArrayExpression linqNewArray, Func<Type, IEnumerable<Expression>, Expression> factory)
231230
{
232231
return factory.Invoke(
233232
linqNewArray.Type.GetElementType(),
234-
linqNewArray.Expressions.Project(ConvertExp));
233+
Convert(linqNewArray.Expressions));
235234
}
236235

237236
private Expression Convert(LinqExp.ConditionalExpression linqConditional)
@@ -317,15 +316,10 @@ private static Expression Convert(LinqExp.ConstantExpression linqConstant)
317316

318317
private Expression Convert(LinqExp.MethodCallExpression linqCall)
319318
{
320-
var arguments = linqCall.Arguments.Project(arg =>
321-
(arg.NodeType == LinqExp.ExpressionType.Quote)
322-
? Expression.Constant(((LinqExp.UnaryExpression)arg).Operand, arg.Type)
323-
: ConvertExp(arg));
324-
325319
return Expression.Call(
326320
ConvertExp(linqCall.Object),
327321
linqCall.Method,
328-
arguments);
322+
Convert(linqCall.Arguments));
329323
}
330324

331325
private Expression Convert(LinqExp.MemberExpression linqMemberAccess)
@@ -352,6 +346,14 @@ private ParameterExpression Convert(LinqExp.ParameterExpression linqParam)
352346

353347
return _parameters[linqParam] = Expression.Parameter(linqParam.Type, linqParam.Name);
354348
}
349+
350+
private IEnumerable<Expression> Convert(IEnumerable<LinqExp.Expression> linqExpressions)
351+
{
352+
return linqExpressions.Project(arg =>
353+
(arg.NodeType == LinqExp.ExpressionType.Quote)
354+
? Expression.Constant(((LinqExp.UnaryExpression)arg).Operand, arg.Type)
355+
: ConvertExp(arg));
356+
}
355357
}
356358
}
357359
}

0 commit comments

Comments
 (0)