From 789661ccf76a5c3262bdc1d4ad9628e4cf55f726 Mon Sep 17 00:00:00 2001 From: Aaron Sulwer Date: Tue, 25 Jun 2024 15:17:21 -0700 Subject: [PATCH] updated System.Linq.Dynamic.Core to 'fix' improperly used literal notation --- CHANGELOG.md | 22 ++++++++------ ROADMAP.md | 2 +- .../RuleExpressionParserTests.cs | 30 +++++++++++++++++++ RulesEngine/RulesEngine.csproj | 4 +-- 4 files changed, 46 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6078e75e..bac4099c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,24 +2,28 @@ All notable changes to this project will be documented in this file. +## [6.0.3] +- updated System.Linq.Dynamic.Core to fix a bug [614](https://github.com/microsoft/RulesEngine/issues/614) +- created test CachingLiteralsDictionary to verify bug has been fixed + ## [6.0.2] - - CancellationToken was not completely implemented - - Release builds are strongly signed +- CancellationToken was not completely implemented +- Release builds are strongly signed ## [6.0.1] - - All previous RulesEngine public methods have labeled obsolete (but still exist for backwards compatibility) - - Replacement methods created which prevent confusion [Example](https://github.com/asulwer/RulesEngine/blob/main/demo/DemoApp/Demos/MultipleWorkflows.cs) +- All previous RulesEngine public methods have labeled obsolete (but still exist for backwards compatibility) +- Replacement methods created which prevent confusion [Example](https://github.com/asulwer/RulesEngine/blob/main/demo/DemoApp/Demos/MultipleWorkflows.cs) - `public async IAsyncEnumerable> ExecuteAllWorkflows(object[] inputs, [EnumeratorCancellation] CancellationToken ct = default)` - `public async IAsyncEnumerable> ExecuteAllWorkflows(RuleParameter[] inputs, [EnumeratorCancellation] CancellationToken ct = default)` - - interates workflows and calls ExecuteWorkflow for each interation - - yield return for each workflow + - interates workflows and calls ExecuteWorkflow for each interation + - yield return for each workflow - `public async Task> ExecuteWorkflow(string workflow_name, object[] inputs, CancellationToken ct = default)` - `public async Task> ExecuteWorkflow(string workflow_name, RuleParameter[] inputs, CancellationToken ct = default)` - - interates rules in workflow and calls ExecuteRule for each iteration + - interates rules in workflow and calls ExecuteRule for each iteration - `public async Task ExecuteRule(string workflow_name, string rule_name, RuleParameter[] ruleParams, CancellationToken ct = default)` - - executes a rule and/or action, if applicable + - executes a rule and/or action, if applicable - `public async Task ExecuteRuleActions(string workflow_name, string rule_name, RuleParameter[] inputs, CancellationToken ct = default)` - - execute the actions of a rule + - execute the actions of a rule ## [6.0.0] - methods that were marked obsolete, in prior version, have been removed diff --git a/ROADMAP.md b/ROADMAP.md index c4d56a52..035e4789 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -1,4 +1,4 @@ -# Roadmap for RulesEngineEx, formerlly known as [RulesEngine}(https://github.com/microsoft/RulesEngine). +### Roadmap for RulesEngineEx, formerlly known as [RulesEngine}(https://github.com/microsoft/RulesEngine). - WorkflowName and RuleName will be changed to Name - seems redundant to say Workflow.WorkflowName or Rule.RuleName diff --git a/RulesEngine.UnitTest/RuleExpressionParserTests/RuleExpressionParserTests.cs b/RulesEngine.UnitTest/RuleExpressionParserTests/RuleExpressionParserTests.cs index d66cca79..0bc3baed 100644 --- a/RulesEngine.UnitTest/RuleExpressionParserTests/RuleExpressionParserTests.cs +++ b/RulesEngine.UnitTest/RuleExpressionParserTests/RuleExpressionParserTests.cs @@ -3,8 +3,11 @@ using Newtonsoft.Json.Linq; using RulesEngine.ExpressionBuilders; +using RulesEngine.Models; +using System; using System.Diagnostics.CodeAnalysis; using Xunit; +using static FastExpressionCompiler.ExpressionCompiler; namespace RulesEngine.UnitTest.RuleExpressionParserTests { @@ -50,6 +53,33 @@ public void TestExpressionWithJObject() Assert.Equal("helloworld", value3); } + [Fact] + public void CachingLiteralsDictionary() + { + var board = new { NumberOfMembers = default(decimal?) }; + + var parameters = new RuleParameter[] { + RuleParameter.Create("Board", board) + }; + + var parser = new RuleExpressionParser(); + + try + { + const string expression1 = "Board.NumberOfMembers = 0.2d"; + var result1 = parser.Evaluate(expression1, parameters); + Assert.False(result1); + } + catch (Exception) + { + // passing it over. + } + + const string expression2 = "Board.NumberOfMembers = 0.2"; //literal notation incorrect, should be 0.2m + var result2 = parser.Evaluate(expression2, parameters); + Assert.False(result2); + } + [Theory] [InlineData(false)] public void TestExpressionWithDifferentCompilerSettings(bool fastExpressionEnabled){ diff --git a/RulesEngine/RulesEngine.csproj b/RulesEngine/RulesEngine.csproj index 10fe1232..afcf0d9a 100644 --- a/RulesEngine/RulesEngine.csproj +++ b/RulesEngine/RulesEngine.csproj @@ -3,7 +3,7 @@ netstandard2.1 disable - 6.0.2.1 + 6.0.3 RulesEngineEx Copyright (c) Aaron Sulwer. ACCLS Company @@ -48,7 +48,7 @@ - +