Skip to content

Commit

Permalink
Merge branch 'main' into stj
Browse files Browse the repository at this point in the history
  • Loading branch information
YogeshPraj authored Aug 23, 2024
2 parents bc6b0ec + d7c92c2 commit 47dea16
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnetcore-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: ./scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 96

- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2.2.1
uses: coverallsapp/github-action@v2.3.0
if: ${{ github.event_name == 'push' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ Add it in your ReSettings and pass in RulesEngine constructor
```c#
var reSettings = new ReSettings{
CustomTypes = new Type[] { typeof(Utils) }
}
};

var rulesEngine = new RulesEngine.RulesEngine(workflowRules,reSettings);
```
Expand Down Expand Up @@ -275,7 +275,7 @@ LocalParams are defined at rule level and can be used by the rule and its child

These rules when executed with the below input will return success
```c#
var input = new RuleParameter("myInput",new {
var rp = new RuleParameter("myInput",new {
hello = "HELLO"
});

Expand Down Expand Up @@ -404,7 +404,7 @@ Define OnSuccess or OnFailure Action for your Rule:
"OnFailure": { // This will execute if the Rule evaluates to failure
"Name": "EvaluateRule",
"Context": {
"WorkflowName": "inputWorkflow",
"workflowName": "inputWorkflow",
"ruleName": "GiveDiscount10Percent"
}
}
Expand Down Expand Up @@ -443,7 +443,7 @@ EvaluateRule also supports passing filtered inputs and computed inputs to chaine
"OnSuccess": {
"Name": "EvaluateRule",
"Context": {
"WorkflowName": "inputWorkflow",
"workflowName": "inputWorkflow",
"ruleName": "GiveDiscount10Percent",
"inputFilter": ["input2"], //will only pass input2 from existing inputs,scopedparams to the chained rule
"additionalInputs":[ // will pass a new input named currentDiscount with the result of the expression to the chained rule
Expand Down Expand Up @@ -583,4 +583,4 @@ Here are the all the options available:-
| Value | Description |
| --- | --- |
| `All` | Executes all nested rules. |
| `Performance` | Skips nested rules whose execution does not impact parent rule's result. |
| `Performance` | Skips nested rules whose execution does not impact parent rule's result. |
7 changes: 7 additions & 0 deletions src/RulesEngine/Actions/ActionContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ public bool TryGetContext<T>(string name,out T output)
{
try
{
//key not found return
//Returning a KeyNotFoundException has a significant impact on performance.
if (!_context.ContainsKey(name))
{
output = default(T);
return false;
}
output = GetContext<T>(name);
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/RulesEngine/CustomTypeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
using RulesEngine.HelperFunctions;
using System;
using System.Collections.Generic;
using System.Linq.Dynamic.Core;
using System.Linq.Dynamic.Core.CustomTypeProviders;

namespace RulesEngine
{
public class CustomTypeProvider : DefaultDynamicLinqCustomTypeProvider
{
private HashSet<Type> _types;
public CustomTypeProvider(Type[] types) : base()
public CustomTypeProvider(Type[] types) : base(ParsingConfig.Default)
{
_types = new HashSet<Type>(types ?? new Type[] { });
_types.Add(typeof(ExpressionUtils));
Expand Down
6 changes: 5 additions & 1 deletion src/RulesEngine/RulesEngine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
<ItemGroup>
<PackageReference Include="FastExpressionCompiler" Version="4.1.0" />
<PackageReference Include="FluentValidation" Version="11.9.0" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.7" />

<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.3" />

<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
</ItemGroup>

Expand All @@ -48,8 +50,10 @@
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">

<PackageReference Include="System.Text.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0"/>

</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion test/RulesEngine.UnitTest/RulesEngine.UnitTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageReference Include="AutoFixture" Version="4.18.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="System.Text.Json" Version="8.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="xunit" Version="2.6.5" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
<PrivateAssets>all</PrivateAssets>
Expand Down

0 comments on commit 47dea16

Please sign in to comment.