rules-framework icon indicating copy to clipboard operation
rules-framework copied to clipboard

InMemory providers always returns same instance of rules' object

Open martinhonovais opened this issue 2 years ago • 1 comments

RuleBuilder
    .NewRule<ContentTypes, ConditionTypes>()
    .WithName(RmaInvoiceDisclaimerForShippingCostV3)
    .WithContent(
        ContentTypes.RmaDisclaimerShippingCost,
        new DisclaimersValue(
        "Freight Cost of {Shipping.AmountInclTax} not to be included in grand total")
    )
    .WithDateBegin(DateTime.Parse("2019-01-01"))
    .Build(),
RuleAddPriorityOption.ByPriorityNumber(1) 

Take the above example, if the rule was configured on this away, whenever this rule matches the condition, the instance of the object DisclaimersValue returned is going to be always the same. It means that if the application changes the content of the object then it will be changed for the entire application.

Perhaps the behavior here should be the rules framework returning a new instance of the object for each time that the rules match the conditions.

martinhonovais avatar Apr 18 '22 16:04 martinhonovais

Just adding up, this behavior is exclusive to in-memory data source implementation, perhaps the solution can be thought of as part of in-memory implementation (non-binding, just an observation).

luispfgarces avatar Apr 19 '22 08:04 luispfgarces