You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've encountered an unexpected behavior when evaluating an expression using the RulesEngine RuleExpressionParser with default ReSettings. Specifically, an expression that should logically return false is instead returning true. This issue arises under certain conditions when the UseFastExpressionCompiler option is enabled (which is the default setting).
Steps to Reproduce
Use the following code snippet to set up a basic evaluation scenario with RulesEngine:
usingRulesEngine.ExpressionBuilders;usingRulesEngine.Models;// Setup a parameter with null valuesvarparameter=RuleParameter.Create("Item",new{Value1=(decimal?)null,Value2=(decimal?)null});// Initialize the parser with default settingsvarparser=newRuleExpressionParser(newReSettings());// Define an expression that should evaluate to falseconststringexpression=@"Item.Value1 / Item.Value2 < 0.2";// Evaluate the expressionvarresult=parser.Evaluate<bool>(expression,new[]{parameter});// Output the resultConsole.WriteLine(result);Console.ReadLine();
Run the above code. The output is True, which is unexpected based on the expression logic.
Expected Behavior
Given the expression Item.Value1 / Item.Value2 < 0.2 and both Item.Value1 and Item.Value2 being null, the expected result should logically be False since the comparison cannot be meaningfully made.
Observed Behavior
When executing the provided code snippet, the evaluation result is True, which contradicts the expected logical outcome.
Workaround
The issue can be mitigated by disabling the UseFastExpressionCompiler option in the ReSettings:
Disabling UseFastExpressionCompiler yields the correct evaluation result.
Suggested Next Steps
It seems there might be a bug in how expressions are compiled or evaluated when UseFastExpressionCompiler is enabled. It would be beneficial for the maintainers to investigate this behavior further to understand the underlying cause and implement a fix.
I believe this issue could affect others who rely on the default behavior of the RulesEngine, and making the community aware of this potential pitfall (and the workaround) could prevent confusion and errors in expression evaluations.
The text was updated successfully, but these errors were encountered:
I've encountered an unexpected behavior when evaluating an expression using the RulesEngine
RuleExpressionParser
with defaultReSettings
. Specifically, an expression that should logically returnfalse
is instead returningtrue
. This issue arises under certain conditions when theUseFastExpressionCompiler
option is enabled (which is the default setting).Steps to Reproduce
RulesEngine
:True
, which is unexpected based on the expression logic.Expected Behavior
Given the expression
Item.Value1 / Item.Value2 < 0.2
and bothItem.Value1
andItem.Value2
beingnull
, the expected result should logically beFalse
since the comparison cannot be meaningfully made.Observed Behavior
When executing the provided code snippet, the evaluation result is
True
, which contradicts the expected logical outcome.Workaround
The issue can be mitigated by disabling the
UseFastExpressionCompiler
option in theReSettings
:Disabling
UseFastExpressionCompiler
yields the correct evaluation result.Suggested Next Steps
It seems there might be a bug in how expressions are compiled or evaluated when
UseFastExpressionCompiler
is enabled. It would be beneficial for the maintainers to investigate this behavior further to understand the underlying cause and implement a fix.I believe this issue could affect others who rely on the default behavior of the
RulesEngine
, and making the community aware of this potential pitfall (and the workaround) could prevent confusion and errors in expression evaluations.The text was updated successfully, but these errors were encountered: