Skip to content

An unexpected exception is thrown by System.Linq.Expressions.Expression.ValidateUserDefinedConditionalLogicOperator when nullable value types are involved #115674

Open
@AlekseyTs

Description

@AlekseyTs

Description

See:

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions