Skip to content

ByRef Lambda parameters are not marked as such in the output of ToReadableString #106

Closed
@rpetz

Description

@rpetz

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;
    }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions