Open
Description
Description
See:
- Invalid code is emitted for a user-defined conditional logical operator roslyn#78609 (comment)
- Invalid code is emitted for a user-defined conditional logical operator roslyn#78609 (comment)
- Invalid code is emitted for a user-defined conditional logical operator roslyn#78609 (comment)
I assume both AndAlso
and OrElse
factories are affected.
It is quite possible that if creation of such trees will be allowed, expression trees interpretation and compilation might need fixing as well.
Reproduction Steps
See above
Expected behavior
It should be possible to create, interpret and compile+execute such trees
Actual behavior
System.ArgumentException: The user-defined operator method 'op_BitwiseAnd' for operator 'AndAlso' must have associated boolean True and False operators.
at System.Linq.Expressions.Expression.ValidateUserDefinedConditionalLogicOperator(ExpressionType nodeType, Type left, Type right, MethodInfo method)
at System.Linq.Expressions.Expression.AndAlso(Expression left, Expression right, MethodInfo method)
Regression?
Unlikely
Known Workarounds
None known at the moment
Configuration
No response
Other information
I think it will be good to add an overload that explicitly takes MethodInfo for boolean True/False operator. And having a conversion lambda for the argument wouldn't hurt, that is if we would want to support extension operators.