microsoft / RulesEngine

A Json based Rules Engine with extensive Dynamic expression support
https://microsoft.github.io/RulesEngine/
MIT License
3.6k stars 543 forks source link

Different Behavior when running in Linux vs Windows #509

Closed khPhoenix closed 1 year ago

khPhoenix commented 1 year ago

I recently came across an issue while implementing RulesEngine in a .Net 7 project. I was able to setup my rules and they were running correctly when running on my Windows Development machine, but when deployed in a Linux docker container, they were not acting as expected.

Environment Details: Running in WSL:

"RulesEngine" Version="5.0.1"

dotnet --version 7.0.306

cat /etc/os-release NAME="Ubuntu" VERSION="20.04.5 LTS (Focal Fossa)"

uname -r 5.10.16.3-microsoft-standard-WSL2

Running in Docker/EC2

"RulesEngine" Version="5.0.1"

mcr.microsoft.com/dotnet/aspnet:7.0

For the provided Rule below, in windows the Activation Rule isSuccess evaluates to false as expected, Deactivation Rule isSuccess evaluates to true.

When running in Linux, as shown below, the results are the opposite of expected.

We were able to find a work around by removing the Global Param and hard coding it into the rule. After doing that the rule evaluated correctly.

Rule Json:

[
    {
        "WorkflowName": "MyWorkflow",
        "WorkflowsToInject": null,
        "RuleExpressionType": 0,
        "GlobalParams": [
            {
                "Name": "threshold",
                "Expression": "double.Parse(\u00220.25\u0022)"
            }
        ],
        "Rules": [
            {
                "RuleName": "Activation",
                "Properties": null,
                "Operator": null,
                "ErrorMessage": null,
                "Enabled": true,
                "RuleExpressionType": 0,
                "WorkflowsToInject": null,
                "Rules": null,
                "LocalParams": [
                    {
                        "Name": "ruleCount",
                        "Expression": "int.Parse(\u002215\u0022)"
                    }
                ],
                "Expression": "input1.Count \u003E= ruleCount \u0026\u0026 input1.Where(x =\u003E x.Value \u003E= threshold).Count() \u003E= ruleCount",
                "Actions": null,
                "SuccessEvent": null
            },
            {
                "RuleName": "Deactivation",
                "Properties": null,
                "Operator": null,
                "ErrorMessage": null,
                "Enabled": true,
                "RuleExpressionType": 0,
                "WorkflowsToInject": null,
                "Rules": null,
                "LocalParams": [
                    {
                        "Name": "ruleCount",
                        "Expression": "int.Parse(\u002230\u0022)"
                    }
                ],
                "Expression": "input1.Count \u003E= ruleCount \u0026\u0026 input1.OrderByDescending(o =\u003E o.ChangeDateTime).Take(ruleCount).All(a =\u003E a.Value \u003C threshold)",
                "Actions": null,
                "SuccessEvent": null
            }
        ]
    }
]

Evaluation result from Linux

[{
    "Rule": {
        "RuleName": "Activation",
        "Properties": null,
        "Operator": null,
        "ErrorMessage": null,
        "Enabled": true,
        "RuleExpressionType": 0,
        "WorkflowsToInject": null,
        "Rules": null,
        "LocalParams": [
            {
                "Name": "ruleCount",
                "Expression": "int.Parse(\"15\")"
            }
        ],
        "Expression": "input1.Count >= ruleCount && input1.Where(x => x.Value >= threshold).Count() >= ruleCount",
        "Actions": null,
        "SuccessEvent": null
    },
    "IsSuccess": true,
    "ChildResults": null,
    "Inputs": {
        "input1": [
            {
                "Value": 0.13259286,
                "ChangeDateTime": "2023-07-28T19:57:07.432339Z"
            },
            {
                "Value": 0.09435427,
                "ChangeDateTime": "2023-07-28T19:58:04.536459Z"
            },
            {
                "Value": 0.14896593,
                "ChangeDateTime": "2023-07-28T19:59:08.682072Z"
            },
            {
                "Value": 0.12852388,
                "ChangeDateTime": "2023-07-28T20:00:06.78036Z"
            },
            {
                "Value": 0.17011189,
                "ChangeDateTime": "2023-07-28T20:00:54.873615Z"
            },
            {
                "Value": 0.0532116,
                "ChangeDateTime": "2023-07-28T20:02:52.04049Z"
            },
            {
                "Value": 0.04064374,
                "ChangeDateTime": "2023-07-28T20:03:54.168499Z"
            },
            {
                "Value": 0.03748944,
                "ChangeDateTime": "2023-07-28T20:03:54.194786Z"
            },
            {
                "Value": 0.07752395,
                "ChangeDateTime": "2023-07-28T20:06:32.451464Z"
            },
            {
                "Value": 0.07294922,
                "ChangeDateTime": "2023-07-28T20:07:38.691755Z"
            },
            {
                "Value": 0.09892442,
                "ChangeDateTime": "2023-07-28T20:08:37.98802Z"
            },
            {
                "Value": 0.06370641,
                "ChangeDateTime": "2023-07-28T20:05:41.358461Z"
            },
            {
                "Value": 0.07550429,
                "ChangeDateTime": "2023-07-28T20:09:48.129748Z"
            },
            {
                "Value": 0.0653021,
                "ChangeDateTime": "2023-07-28T20:10:48.274482Z"
            },
            {
                "Value": 0.09304246,
                "ChangeDateTime": "2023-07-28T20:11:49.436983Z"
            },
            {
                "Value": 0.0797422,
                "ChangeDateTime": "2023-07-28T20:12:53.609118Z"
            },
            {
                "Value": 0.08211832,
                "ChangeDateTime": "2023-07-28T20:13:52.699728Z"
            },
            {
                "Value": 0.06955433,
                "ChangeDateTime": "2023-07-28T20:15:03.843289Z"
            },
            {
                "Value": 0.07626661,
                "ChangeDateTime": "2023-07-28T20:15:03.870057Z"
            },
            {
                "Value": 0.05033984,
                "ChangeDateTime": "2023-07-28T20:16:17.032262Z"
            },
            {
                "Value": 0.05202596,
                "ChangeDateTime": "2023-07-28T20:17:20.172669Z"
            },
            {
                "Value": 0.06861198,
                "ChangeDateTime": "2023-07-28T20:18:32.303309Z"
            },
            {
                "Value": 0.04935532,
                "ChangeDateTime": "2023-07-28T20:19:33.451426Z"
            },
            {
                "Value": 0.04073699,
                "ChangeDateTime": "2023-07-28T20:20:37.737395Z"
            },
            {
                "Value": 0.02164916,
                "ChangeDateTime": "2023-07-28T20:21:38.883635Z"
            },
            {
                "Value": 0.01334031,
                "ChangeDateTime": "2023-07-28T20:22:40.053193Z"
            },
            {
                "Value": 0.0336915,
                "ChangeDateTime": "2023-07-28T20:23:44.240297Z"
            },
            {
                "Value": 0.04870055,
                "ChangeDateTime": "2023-07-28T20:26:33.584756Z"
            },
            {
                "Value": 0.07125243,
                "ChangeDateTime": "2023-07-28T20:28:11.7889Z"
            },
            {
                "Value": 0.04904275,
                "ChangeDateTime": "2023-07-28T20:24:40.346216Z"
            },
            {
                "Value": 0.03625701,
                "ChangeDateTime": "2023-07-28T20:27:20.707478Z"
            },
            {
                "Value": 0.05703328,
                "ChangeDateTime": "2023-07-28T20:28:57.876436Z"
            },
            {
                "Value": 0.04364996,
                "ChangeDateTime": "2023-07-28T20:25:43.496357Z"
            },
            {
                "Value": 0.07558272,
                "ChangeDateTime": "2023-07-28T20:30:11.023295Z"
            },
            {
                "Value": 0.03073958,
                "ChangeDateTime": "2023-07-28T20:33:00.347672Z"
            },
            {
                "Value": 0.0341309,
                "ChangeDateTime": "2023-07-28T20:33:59.790621Z"
            },
            {
                "Value": 0.05270871,
                "ChangeDateTime": "2023-07-28T20:31:15.166193Z"
            },
            {
                "Value": 0.09138862,
                "ChangeDateTime": "2023-07-28T20:32:08.259273Z"
            },
            {
                "Value": 0.15922104,
                "ChangeDateTime": "2023-07-28T20:35:12.963809Z"
            },
            {
                "Value": 0.11383641,
                "ChangeDateTime": "2023-07-28T20:36:26.120815Z"
            },
            {
                "Value": 0.12404025,
                "ChangeDateTime": "2023-07-28T20:37:37.27212Z"
            },
            {
                "Value": 0.06010197,
                "ChangeDateTime": "2023-07-28T20:38:47.409412Z"
            },
            {
                "Value": 0.08396237,
                "ChangeDateTime": "2023-07-28T20:39:37.504217Z"
            },
            {
                "Value": 0.06731881,
                "ChangeDateTime": "2023-07-28T20:40:27.588895Z"
            },
            {
                "Value": 0.05617253,
                "ChangeDateTime": "2023-07-28T20:41:33.760373Z"
            },
            {
                "Value": 0.0585155,
                "ChangeDateTime": "2023-07-28T20:42:26.847144Z"
            },
            {
                "Value": 0.06793098,
                "ChangeDateTime": "2023-07-28T20:43:36.988904Z"
            },
            {
                "Value": 0.06879344,
                "ChangeDateTime": "2023-07-28T20:44:46.133926Z"
            },
            {
                "Value": 0.06931814,
                "ChangeDateTime": "2023-07-28T20:45:50.275932Z"
            },
            {
                "Value": 0.04802603,
                "ChangeDateTime": "2023-07-28T20:46:36.367289Z"
            },
            {
                "Value": 0.04036225,
                "ChangeDateTime": "2023-07-28T20:47:27.484188Z"
            },
            {
                "Value": 0.04968483,
                "ChangeDateTime": "2023-07-28T20:48:13.582228Z"
            },
            {
                "Value": 0.0773483,
                "ChangeDateTime": "2023-07-28T19:49:16.354277Z"
            },
            {
                "Value": 0.08710921,
                "ChangeDateTime": "2023-07-28T19:48:25.253743Z"
            },
            {
                "Value": 0.07665287,
                "ChangeDateTime": "2023-07-28T19:50:25.496642Z"
            },
            {
                "Value": 0.06121748,
                "ChangeDateTime": "2023-07-28T19:51:20.644955Z"
            },
            {
                "Value": 0.04179136,
                "ChangeDateTime": "2023-07-28T19:52:26.793369Z"
            },
            {
                "Value": 0.13522345,
                "ChangeDateTime": "2023-07-28T19:54:19.051669Z"
            },
            {
                "Value": 0.08536856,
                "ChangeDateTime": "2023-07-28T19:56:04.287806Z"
            },
            {
                "Value": 0.05041369,
                "ChangeDateTime": "2023-07-28T19:53:18.901696Z"
            },
            {
                "Value": 0.1627249,
                "ChangeDateTime": "2023-07-28T19:55:13.160235Z"
            },
            {
                "Value": 0.05,
                "ChangeDateTime": "2023-07-28T19:54:03.2197Z"
            },
            {
                "Value": 0.05,
                "ChangeDateTime": "2023-07-28T19:56:00.802023Z"
            },
            {
                "Value": 0.02792705297470093,
                "ChangeDateTime": "2023-07-28T20:49:03.6825337Z"
            }
        ],
        "threshold": 0.25,
        "ruleCount": 15
    },
    "ActionResult": {
        "Output": null,
        "Exception": null
    },
    "ExceptionMessage": ""
},{
    "Rule": {
        "RuleName": "Deactivation",
        "Properties": null,
        "Operator": null,
        "ErrorMessage": null,
        "Enabled": true,
        "RuleExpressionType": 0,
        "WorkflowsToInject": null,
        "Rules": null,
        "LocalParams": [
            {
                "Name": "ruleCount",
                "Expression": "int.Parse(\"30\")"
            }
        ],
        "Expression": "input1.Count >= ruleCount && input1.OrderByDescending(o => o.ChangeDateTime).Take(ruleCount).All(a => a.Value < threshold)",
        "Actions": null,
        "SuccessEvent": null
    },
    "IsSuccess": false,
    "ChildResults": null,
    "Inputs": {
        "input1": [
            {
                "Value": 0.13259286,
                "ChangeDateTime": "2023-07-28T19:57:07.432339Z"
            },
            {
                "Value": 0.09435427,
                "ChangeDateTime": "2023-07-28T19:58:04.536459Z"
            },
            {
                "Value": 0.14896593,
                "ChangeDateTime": "2023-07-28T19:59:08.682072Z"
            },
            {
                "Value": 0.12852388,
                "ChangeDateTime": "2023-07-28T20:00:06.78036Z"
            },
            {
                "Value": 0.17011189,
                "ChangeDateTime": "2023-07-28T20:00:54.873615Z"
            },
            {
                "Value": 0.0532116,
                "ChangeDateTime": "2023-07-28T20:02:52.04049Z"
            },
            {
                "Value": 0.04064374,
                "ChangeDateTime": "2023-07-28T20:03:54.168499Z"
            },
            {
                "Value": 0.03748944,
                "ChangeDateTime": "2023-07-28T20:03:54.194786Z"
            },
            {
                "Value": 0.07752395,
                "ChangeDateTime": "2023-07-28T20:06:32.451464Z"
            },
            {
                "Value": 0.07294922,
                "ChangeDateTime": "2023-07-28T20:07:38.691755Z"
            },
            {
                "Value": 0.09892442,
                "ChangeDateTime": "2023-07-28T20:08:37.98802Z"
            },
            {
                "Value": 0.06370641,
                "ChangeDateTime": "2023-07-28T20:05:41.358461Z"
            },
            {
                "Value": 0.07550429,
                "ChangeDateTime": "2023-07-28T20:09:48.129748Z"
            },
            {
                "Value": 0.0653021,
                "ChangeDateTime": "2023-07-28T20:10:48.274482Z"
            },
            {
                "Value": 0.09304246,
                "ChangeDateTime": "2023-07-28T20:11:49.436983Z"
            },
            {
                "Value": 0.0797422,
                "ChangeDateTime": "2023-07-28T20:12:53.609118Z"
            },
            {
                "Value": 0.08211832,
                "ChangeDateTime": "2023-07-28T20:13:52.699728Z"
            },
            {
                "Value": 0.06955433,
                "ChangeDateTime": "2023-07-28T20:15:03.843289Z"
            },
            {
                "Value": 0.07626661,
                "ChangeDateTime": "2023-07-28T20:15:03.870057Z"
            },
            {
                "Value": 0.05033984,
                "ChangeDateTime": "2023-07-28T20:16:17.032262Z"
            },
            {
                "Value": 0.05202596,
                "ChangeDateTime": "2023-07-28T20:17:20.172669Z"
            },
            {
                "Value": 0.06861198,
                "ChangeDateTime": "2023-07-28T20:18:32.303309Z"
            },
            {
                "Value": 0.04935532,
                "ChangeDateTime": "2023-07-28T20:19:33.451426Z"
            },
            {
                "Value": 0.04073699,
                "ChangeDateTime": "2023-07-28T20:20:37.737395Z"
            },
            {
                "Value": 0.02164916,
                "ChangeDateTime": "2023-07-28T20:21:38.883635Z"
            },
            {
                "Value": 0.01334031,
                "ChangeDateTime": "2023-07-28T20:22:40.053193Z"
            },
            {
                "Value": 0.0336915,
                "ChangeDateTime": "2023-07-28T20:23:44.240297Z"
            },
            {
                "Value": 0.04870055,
                "ChangeDateTime": "2023-07-28T20:26:33.584756Z"
            },
            {
                "Value": 0.07125243,
                "ChangeDateTime": "2023-07-28T20:28:11.7889Z"
            },
            {
                "Value": 0.04904275,
                "ChangeDateTime": "2023-07-28T20:24:40.346216Z"
            },
            {
                "Value": 0.03625701,
                "ChangeDateTime": "2023-07-28T20:27:20.707478Z"
            },
            {
                "Value": 0.05703328,
                "ChangeDateTime": "2023-07-28T20:28:57.876436Z"
            },
            {
                "Value": 0.04364996,
                "ChangeDateTime": "2023-07-28T20:25:43.496357Z"
            },
            {
                "Value": 0.07558272,
                "ChangeDateTime": "2023-07-28T20:30:11.023295Z"
            },
            {
                "Value": 0.03073958,
                "ChangeDateTime": "2023-07-28T20:33:00.347672Z"
            },
            {
                "Value": 0.0341309,
                "ChangeDateTime": "2023-07-28T20:33:59.790621Z"
            },
            {
                "Value": 0.05270871,
                "ChangeDateTime": "2023-07-28T20:31:15.166193Z"
            },
            {
                "Value": 0.09138862,
                "ChangeDateTime": "2023-07-28T20:32:08.259273Z"
            },
            {
                "Value": 0.15922104,
                "ChangeDateTime": "2023-07-28T20:35:12.963809Z"
            },
            {
                "Value": 0.11383641,
                "ChangeDateTime": "2023-07-28T20:36:26.120815Z"
            },
            {
                "Value": 0.12404025,
                "ChangeDateTime": "2023-07-28T20:37:37.27212Z"
            },
            {
                "Value": 0.06010197,
                "ChangeDateTime": "2023-07-28T20:38:47.409412Z"
            },
            {
                "Value": 0.08396237,
                "ChangeDateTime": "2023-07-28T20:39:37.504217Z"
            },
            {
                "Value": 0.06731881,
                "ChangeDateTime": "2023-07-28T20:40:27.588895Z"
            },
            {
                "Value": 0.05617253,
                "ChangeDateTime": "2023-07-28T20:41:33.760373Z"
            },
            {
                "Value": 0.0585155,
                "ChangeDateTime": "2023-07-28T20:42:26.847144Z"
            },
            {
                "Value": 0.06793098,
                "ChangeDateTime": "2023-07-28T20:43:36.988904Z"
            },
            {
                "Value": 0.06879344,
                "ChangeDateTime": "2023-07-28T20:44:46.133926Z"
            },
            {
                "Value": 0.06931814,
                "ChangeDateTime": "2023-07-28T20:45:50.275932Z"
            },
            {
                "Value": 0.04802603,
                "ChangeDateTime": "2023-07-28T20:46:36.367289Z"
            },
            {
                "Value": 0.04036225,
                "ChangeDateTime": "2023-07-28T20:47:27.484188Z"
            },
            {
                "Value": 0.04968483,
                "ChangeDateTime": "2023-07-28T20:48:13.582228Z"
            },
            {
                "Value": 0.0773483,
                "ChangeDateTime": "2023-07-28T19:49:16.354277Z"
            },
            {
                "Value": 0.08710921,
                "ChangeDateTime": "2023-07-28T19:48:25.253743Z"
            },
            {
                "Value": 0.07665287,
                "ChangeDateTime": "2023-07-28T19:50:25.496642Z"
            },
            {
                "Value": 0.06121748,
                "ChangeDateTime": "2023-07-28T19:51:20.644955Z"
            },
            {
                "Value": 0.04179136,
                "ChangeDateTime": "2023-07-28T19:52:26.793369Z"
            },
            {
                "Value": 0.13522345,
                "ChangeDateTime": "2023-07-28T19:54:19.051669Z"
            },
            {
                "Value": 0.08536856,
                "ChangeDateTime": "2023-07-28T19:56:04.287806Z"
            },
            {
                "Value": 0.05041369,
                "ChangeDateTime": "2023-07-28T19:53:18.901696Z"
            },
            {
                "Value": 0.1627249,
                "ChangeDateTime": "2023-07-28T19:55:13.160235Z"
            },
            {
                "Value": 0.05,
                "ChangeDateTime": "2023-07-28T19:54:03.2197Z"
            },
            {
                "Value": 0.05,
                "ChangeDateTime": "2023-07-28T19:56:00.802023Z"
            },
            {
                "Value": 0.02792705297470093,
                "ChangeDateTime": "2023-07-28T20:49:03.6825337Z"
            }
        ],
        "threshold": 0.25,
        "ruleCount": 30
    },
    "ActionResult": {
        "Output": null,
        "Exception": null
    },
    "ExceptionMessage": ""
}]
djl-85 commented 1 year ago

Hi. Something similar happened to me and downgrading to version 4.0.0 works as expected. It seems something is broken from version 5.0.0.

abbasc52 commented 1 year ago

@khPhoenix can you share if you are using typed object as input or dynamic object?

khPhoenix commented 1 year ago

@abbasc52 using an anonymous type from a linq select: image

abbasc52 commented 1 year ago

Hi @khPhoenix ,

I am able to reproduce your issue and there seems to be some weird behavior related to double.Parse. If i replace double.Parse with float.Parse it works as expected. If i keep global param as string and then used double.Parse in expression that too works.

I will need to dig deeper on this, since it looks like a corner case scenario. But current workaround would be to work with float.Parse or parsing it in final expression

This is the code generated in this case scenario which looks valid to me:

((input1.Count >= ruleCount) AndAlso (input1.Where(Param_0 => (Param_0.Value >= threshold)).Count() >= ruleCount))
(Func<object[], bool>)((object[] args) =>
{
    List<f__AnonymousType6<double, string>> input1;
    double threshold;
    int ruleCount;
    input1 = ((List<f__AnonymousType6<double, string>>)args[0]);
    threshold = ((double)args[1]);
    ruleCount = ((int)args[2]);
    return ((input1.Count >= ruleCount) && (Enumerable.Count<f__AnonymousType6<double, string>>(Enumerable.Where<f__AnonymousType6<double, string>>(
        input1,
        (Func<f__AnonymousType6<double, string>, bool>)((f__AnonymousType6<double, string> ) =>
            (.Value >= threshold)))) >= ruleCount));
});
((input1.Count >= ruleCount) AndAlso input1.OrderByDescending(Param_0 => Param_0.ChangeDateTime).Take(ruleCount).All(Param_1 => (Param_1.Value < threshold)))
(Func<object[], bool>)((object[] args) =>
{
    List<f__AnonymousType6<double, string>> input1;
    double threshold;
    int ruleCount;
    input1 = ((List<f__AnonymousType6<double, string>>)args[0]);
    threshold = ((double)args[1]);
    ruleCount = ((int)args[2]);
    return ((input1.Count >= ruleCount) && Enumerable.All<f__AnonymousType6<double, string>>(
        Enumerable.Take<f__AnonymousType6<double, string>>(
            Enumerable.OrderByDescending<f__AnonymousType6<double, string>, string>(
                input1,
                (Func<f__AnonymousType6<double, string>, string>)((f__AnonymousType6<double, string> ) =>
                    .ChangeDateTime)),
            ruleCount),
        (Func<f__AnonymousType6<double, string>, bool>)((f__AnonymousType6<double, string> ) =>
            (.Value < threshold))));
});
khPhoenix commented 1 year ago

Hi @khPhoenix ,

I am able to reproduce your issue and there seems to be some weird behavior related to double.Parse. If i replace double.Parse with float.Parse it works as expected. If i keep global param as string and then used double.Parse in expression that too works.

I will need to dig deeper on this, since it looks like a corner case scenario. But current workaround would be to work with float.Parse or parsing it in final expression

This is the code generated in this case scenario which looks valid to me:

((input1.Count >= ruleCount) AndAlso (input1.Where(Param_0 => (Param_0.Value >= threshold)).Count() >= ruleCount))
(Func<object[], bool>)((object[] args) =>
{
    List<f__AnonymousType6<double, string>> input1;
    double threshold;
    int ruleCount;
    input1 = ((List<f__AnonymousType6<double, string>>)args[0]);
    threshold = ((double)args[1]);
    ruleCount = ((int)args[2]);
    return ((input1.Count >= ruleCount) && (Enumerable.Count<f__AnonymousType6<double, string>>(Enumerable.Where<f__AnonymousType6<double, string>>(
        input1,
        (Func<f__AnonymousType6<double, string>, bool>)((f__AnonymousType6<double, string> ) =>
            (.Value >= threshold)))) >= ruleCount));
});
((input1.Count >= ruleCount) AndAlso input1.OrderByDescending(Param_0 => Param_0.ChangeDateTime).Take(ruleCount).All(Param_1 => (Param_1.Value < threshold)))
(Func<object[], bool>)((object[] args) =>
{
    List<f__AnonymousType6<double, string>> input1;
    double threshold;
    int ruleCount;
    input1 = ((List<f__AnonymousType6<double, string>>)args[0]);
    threshold = ((double)args[1]);
    ruleCount = ((int)args[2]);
    return ((input1.Count >= ruleCount) && Enumerable.All<f__AnonymousType6<double, string>>(
        Enumerable.Take<f__AnonymousType6<double, string>>(
            Enumerable.OrderByDescending<f__AnonymousType6<double, string>, string>(
                input1,
                (Func<f__AnonymousType6<double, string>, string>)((f__AnonymousType6<double, string> ) =>
                    .ChangeDateTime)),
            ruleCount),
        (Func<f__AnonymousType6<double, string>, bool>)((f__AnonymousType6<double, string> ) =>
            (.Value < threshold))));
});

Thanks for the update! I'll use one of the work arounds you listed for now :-)

khPhoenix commented 1 year ago

Interesting the issue isn't presenting with the following workflow:

        var workflow = new AlertWorkflow
        {
            WorkflowName = "MyWorkflow",
            GlobalParams = new List<ScopedParam>
            {
                new ScopedParam
                {
                    Name = "threshold",
                    Expression = "double.Parse(\"0.85\")"
                }
            },
            Rules = new List<Rule>
            {
                new Rule
                {
                    RuleName = AlertWorkflow.ActivationRule,
                    Enabled = true,
                    RuleExpressionType = RuleExpressionType.LambdaExpression,
                    Expression = "input1 > threshold"
                },
                new Rule
                {
                    RuleName = AlertWorkflow.DeactivationRule,
                    Enabled = true,
                    RuleExpressionType = RuleExpressionType.LambdaExpression,
                    Expression = "threshold > input1"
                }
            }
        };
abbasc52 commented 1 year ago

@khPhoenix looks like a bug with latest version of FastExpressionCompiler. I have released v5.0.2 which fixes this.