Closed
Description
When using typeof(...).MakeByRefType()
the resulting output from ToReadableString
fails to include the 'ref' keyword (which ToString
does include).
Here is an example console program to demonstrate:
public delegate void OutDelegate(out bool outExample);
public static void Main()
{
var outVar = Expression.Parameter(typeof(bool).MakeByRefType(), "outExample");
var lambda = Expression.Lambda(Expression.Lambda<OutDelegate>(
Expression.Block(
Expression.Assign(outVar, Expression.Constant(false)),
Expression.Assign(outVar, Expression.Constant(true))), outVar));
Console.WriteLine("ToReadableString output:");
Console.WriteLine(lambda.ToReadableString());
Console.WriteLine();
Console.WriteLine("ToString Output:");
Console.WriteLine(lambda.ToString());
Console.ReadLine();
}
And here is the output of the above program:
ToReadableString output:
() =>
{
outExample =>
{
outExample = false;
outExample = true;
}
}
ToString Output:
() => ref outExample => { ... }
The expected output from ToReadableString
should be:
() =>
{
ref outExample =>
{
outExample = false;
outExample = true;
}
}