1

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

DolceVita
  • 2,090
  • 1
  • 23
  • 35
  • If you convert expressions, can you provide an example of original expression (with "redundant" boolean expressions) and then resulting expression (which you want but cannot achieve)? I don't understand what you mean by redundant boolean expressions in this case. – Evk Jun 10 '16 at 13:41
  • I am trying to convert expression 'x.IsBoolOne || x.IsBoolSecond == false' into the 'IsBoolOne = 1 || IsBoolSecond = 0' - for example. How to distinguish x.IsBoolOne and understand that this is a standalone expression and x.IsBoolSEcond == false is a BinaryExpression? – DolceVita Jun 10 '16 at 13:47

0 Answers0