ReadableExpressions
ReadableExpressions copied to clipboard
Translation of LambdaExpression type "Action" that executes IF statement
Hi,
I'm utilizing this library for some Metaprogramming and am having issues with the rendering of typeof(Action) lambdas. I was wondering if you could submit a fix for the following. I've included a very simplified example... in my actual code the body of the if statement is much longer.
using System;
using System.Linq;
using System.Linq.Expressions;
using AgileObjects.ReadableExpressions;
public class Program
{
public static void Main()
{
var x = Expression.IfThen(Expression.Constant(true), Expression.Empty());
var lamb = Expression.Lambda(x, "someLambda", Enumerable.Empty<ParameterExpression>());
var func = Expression.Variable(lamb.Type, lamb.Name);
var assign = Expression.Assign(func, lamb);
var totalBlock = Expression.Block(new ParameterExpression[]{func}, assign);
Console.WriteLine(totalBlock.ToReadableString(x =>
{
return x.ShowLambdaParameterTypes;
}));
}
}
output is
Action someLambda = () => if (true)
{
};
expected
Action someLambda = () =>
{
if (true)
{
}
};
Hi,
Thanks for letting me know about this - I'll look at the issue and your PR soon.
All the best,
Steve
With apologies for the long delay, this is fixed as of v4.