-
-
Notifications
You must be signed in to change notification settings - Fork 394
Open
Labels
Description
When setting a nullable variable (int?) with a null value, DynamicExpresso throws an evaluation error instead of handling the expression correctly.
var interpreter = new DynamicExpresso.Interpreter();
int? MyVar = null;
interpreter.SetVariable("MyValue", MyVar, typeof(int?));
var result = interpreter.Eval("(MyValue ?? 0) == 2");
Event These Evaluation Fails :
((int?)2 ?? 0) == 2 // Should be true, but throws
((int?)null ?? 0) == 2 // Should be false, but throws
Expected behaviour : The expression should evaluate without error and return false.
Actual behavior: It throws an InvalidOperationException.
Expected issue : DynamicExpresso treats (nullable ?? value) as returning object instead of the underlying type (int in this case).
Can someone please help me identify is it a bug/my wrong of of using and some other way possible to handle the scenario.
I am using Version : 2.19.2 (Latest as of now)