Skip to content

Null check for property of parameter with late binding does not work anymore #325

@AndreasKorn

Description

@AndreasKorn

Checking a property of an input (parameter) object for null stopped working in 2.17.1.
This worked fine in 2.16.1.

  var options = InterpreterOptions.DefaultCaseInsensitive | InterpreterOptions.LambdaExpressions | InterpreterOptions.LateBindObject;
  var interpreter = new Interpreter(options);

  var input = new
  {
    //Prop1 = (object?)null, // works
    Prop1 = new { }, // does not matter what type
  };
  var expressionDelegate = interpreter.ParseAsDelegate<Func<object, bool>>($"input.Prop1 == null", "input")!;
//  var expressionDelegate = interpreter.ParseAsDelegate<Func<object, bool>>($"input.Prop1 == (object)null", "input")!; // also works
  var value = expressionDelegate(input); // exception

With 2.17.1 this throws an exception:
System.InvalidCastException : Unable to cast object of type '<>f__AnonymousType2' to type 'System.Nullable`1[System.Boolean]'.

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