zspitz / ExpressionTreeToString

String representations of expression trees + library of expression tree objects
MIT License
151 stars 12 forks source link

Factory Methods writer visitor: string equality generates calls to MakeBinary instead of Equal #61

Closed zspitz closed 3 years ago

zspitz commented 4 years ago

Something like this:

var prm = Parameter(typeof(string));
return Lambda(
    Equal(prm, prm),
    prm
);

generates:

var $var0 = Parameter(
    typeof(string)
);

Lambda(
    MakeBinary(ExpressionType.Equal, $var0, $var0, false,
        typeof(string).GetMethod("op_Equality")
    ),
    $var0
)
zspitz commented 3 years ago

This is happening because the Equal node specifies a method, and the factory method overload which matches two expressions and a method also takes an additional boolean.

Not fixing this ATM.