Skip to content

Fix ToCSharpString output for boolean equality expressionsΒ #487

@Neskatin

Description

@Neskatin

Description
ToCSharpString() generates invalid output when converting boolean equality expressions.

ToString: (x.MyTestBool == True)
ToCSharpString: (x.MyTestBool;

Example

using System.Linq.Expressions;
using FastExpressionCompiler;

var input = new TestClass() { MyTestBool = true };
var parameter = Expression.Parameter(input.GetType(), "x");
var property = Expression.Property(parameter, nameof(TestClass.MyTestBool));
var exp = Expression.Equal(property, Expression.Constant(true));

Console.WriteLine(exp.ToString()); // => (x.MyTestBool == True)
Console.WriteLine(exp.ToCSharpString()); // => (x.MyTestBool;
 
public class TestClass 
{
    public required bool MyTestBool { get; set; }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions