While using ExpressionVisitor
I was stuck with the redundant boolean expressions.
Let say we have this:
1. x=> x.IsBool == true
2. x=> x.IsBool != true
3. x=> x.IsBool
4. x=> !x.IsBool
5. x=> x.IsBool && x.IsBool == true
1 and 2 work fine since they are BinaryExpressions with the left MemberExpression
and the right ConstantExpression
the case 4 works also as I could detect if it is of the type UnaryExpression (!) and convert it into a BinaryExpression with NotEqal left part and evaluated right part
The problem is with expression 3 and expression 5.
Exp. 3 is just a member, how could I understand if this is a redundant boolean and not just something else? Inside MemberVisitor
I just have a member and no more.
Exp. 5 - is the most biggest problem. Even if I solve somehow the issue with exp. 3, how should I differentiate a member from left redundant part and the member from the normal boolean expression?
I expect that the final conversion would be like this: IsBool = 1 AND IsBool == 1 == 1
(I visitand evaluate 2 times MemberExpression
and converted it to the BinaryExression
).
Thanks