RulesEngine
RulesEngine copied to clipboard
If an execution took an exception in the next runs error message is transfered even if it successes.
If a workflow took an exception in . In the next run error message is transfered even if It successes. Sample code is stated below.
public class HasException
{
internal class TestClass
{
private int counter = 0;
private string simpleProp;
public string SimpleProp {
get {
if (counter++ == 0)
{
throw new ArgumentException("Canım istedi");
}
return simpleProp;
}
set {
simpleProp = value;
}
}
}
public void Run()
{
Console.WriteLine($"Running {nameof(NestedInputDemo)}....");
TestClass instance = new();
instance.SimpleProp = "simpleProp";
Workflow workflow = new();
workflow.WorkflowName = "NestedInputDemoWorkflow1";
workflow.Rules = new List<Rule>() {
new Rule() {
RuleName = "CheckNestedSimpleProp",
RuleExpressionType = RuleExpressionType.LambdaExpression,
Expression = "SimpleProp == \"simpleProp\"",
ErrorMessage = "One or more adjust rules failed."
}
};
var settings = new ReSettings();
settings.UseFastExpressionCompiler = false;
var bre = new RulesEngine.RulesEngine(new Workflow[] { workflow }, settings);
var resultList = bre.ExecuteAllRulesAsync(workflow.WorkflowName, instance).Result;
resultList.OnSuccess((eventName) => {
Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}. {resultList[0].ExceptionMessage}");
}).OnFail(() => {
Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure. {resultList[0].ExceptionMessage}");
});
resultList = bre.ExecuteAllRulesAsync(workflow.WorkflowName, instance).Result;
resultList.OnSuccess((eventName) => {
Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in success - {eventName}");
}).OnFail(() => {
Console.WriteLine($"{workflow.WorkflowName} evaluation resulted in failure");
});
}
}
I have created a pr for fixing this issue https://github.com/microsoft/RulesEngine/pull/592. Also I added a unit test to simulate the problem. Can you help us. This is a critical issue.
this project is no longer maintained but...my fork is. i will look into your code and merge into my fork
your PR has been merged with my fork, manually