Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
pbhal authored Jan 30, 2025
2 parents 4f81529 + 033f458 commit c4b108b
Show file tree
Hide file tree
Showing 32 changed files with 544 additions and 159 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -50,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -64,5 +72,5 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3

11 changes: 7 additions & 4 deletions .github/workflows/dotnetcore-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Install dependencies
run: dotnet restore RulesEngine.sln
Expand All @@ -31,10 +34,10 @@ jobs:

- name: Check Coverage
shell: pwsh
run: ./scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 96
run: ./scripts/check-coverage.ps1 -reportPath coveragereport/Cobertura.xml -threshold 93

- name: Coveralls GitHub Action
uses: coverallsapp/github-action@v2.2.1
uses: coverallsapp/github-action@v2.3.6
if: ${{ github.event_name == 'push' }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [5.0.3]
- Updated dependencies to latest
- Fixed RulesEngine throwing exception when type name is same as input name
- Added config to disable FastCompile for expressions
- Added RuleParameter.Create method for better handling on types when value is null

## [5.0.2]
- Fixed Scoped Params returning incorrect results in some corner case scenarios

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To install this library, download the latest version of [NuGet Package](https://

There are several ways to populate workflows for the Rules Engine as listed below.

You need to store the rules based on the [schema definition](https://github.com/microsoft/RulesEngine/blob/main/schema/workflow-schema.json) given and they can be stored in any store as deemed appropriate like Azure Blob Storage, Cosmos DB, Azure App Configuration, [Entity Framework](https://github.com/microsoft/RulesEngine#entity-framework), SQL Servers, file systems etc. For RuleExpressionType `LamdaExpression`, the rule is written as a [lambda expressions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions).
You need to store the rules based on the [schema definition](https://github.com/microsoft/RulesEngine/blob/main/schema/workflow-schema.json) given and they can be stored in any store as deemed appropriate like Azure Blob Storage, Cosmos DB, Azure App Configuration, [Entity Framework](https://github.com/microsoft/RulesEngine#entity-framework), SQL Servers, file systems etc. For RuleExpressionType `LambdaExpression`, the rule is written as a [lambda expressions](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/statements-expressions-operators/lambda-expressions).

An example rule:

Expand Down
9 changes: 7 additions & 2 deletions benchmark/RulesEngineBenchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using Newtonsoft.Json;
using RulesEngine.Models;
using System;
using System.Collections.Generic;
using System.IO;
using BenchmarkDotNet.Jobs;
using System.Text.Json;

namespace RulesEngineBenchmark
{

[MemoryDiagnoser]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.Net90)]
public class REBenchmark
{
private readonly RulesEngine.RulesEngine rulesEngine;
Expand All @@ -34,7 +39,7 @@ public REBenchmark()
}

var fileData = File.ReadAllText(files[0]);
workflow = JsonConvert.DeserializeObject<List<Workflow>>(fileData);
workflow = JsonSerializer.Deserialize<List<Workflow>>(fileData);

rulesEngine = new RulesEngine.RulesEngine(workflow.ToArray(), new ReSettings {
EnableFormattedErrorMessage = false,
Expand Down
8 changes: 4 additions & 4 deletions benchmark/RulesEngineBenchmark/RulesEngineBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.6" />
<!--<PackageReference Include="RulesEngine" Version="3.0.2" />-->
<PackageReference Include="BenchmarkDotNet" Version="0.14.0" />
<!--<PackageReference Include="RulesEngine" Version="3.0.2" />-->
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\RulesEngine\RulesEngine.csproj" />
<ProjectReference Include="..\..\src\RulesEngine\RulesEngine.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions demo/DemoApp.EFDataExample/DemoApp.EFDataExample.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<RootNamespace>DemoApp.EFDataExample</RootNamespace>
<AssemblyName>DemoApp.EFDataExample</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions demo/DemoApp/DemoApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<StartupObject>DemoApp.Program</StartupObject>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="../../src/RulesEngine/RulesEngine.csproj" />
<ProjectReference Include="..\DemoApp.EFDataExample\DemoApp.EFDataExample.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="Workflows\Discount.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
Expand Down
14 changes: 6 additions & 8 deletions demo/DemoApp/EFDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the MIT License.

using DemoApp.EFDataExample;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using RulesEngine.Models;
using System;
using System.Collections.Generic;
Expand All @@ -15,6 +13,8 @@

namespace DemoApp
{
using System.Text.Json;

public class EFDemo
{
public void Run()
Expand All @@ -24,11 +24,9 @@ public void Run()
var orderInfo = "{\"totalOrders\": 5,\"recurringItems\": 2}";
var telemetryInfo = "{\"noOfVisitsPerMonth\": 10,\"percentageOfBuyingToVisit\": 15}";

var converter = new ExpandoObjectConverter();

dynamic input1 = JsonConvert.DeserializeObject<ExpandoObject>(basicInfo, converter);
dynamic input2 = JsonConvert.DeserializeObject<ExpandoObject>(orderInfo, converter);
dynamic input3 = JsonConvert.DeserializeObject<ExpandoObject>(telemetryInfo, converter);
dynamic input1 = JsonSerializer.Deserialize<ExpandoObject>(basicInfo);
dynamic input2 = JsonSerializer.Deserialize<ExpandoObject>(orderInfo);
dynamic input3 = JsonSerializer.Deserialize<ExpandoObject>(telemetryInfo);

var inputs = new dynamic[]
{
Expand All @@ -42,7 +40,7 @@ public void Run()
throw new Exception("Rules not found.");

var fileData = File.ReadAllText(files[0]);
var workflow = JsonConvert.DeserializeObject<List<Workflow>>(fileData);
var workflow = JsonSerializer.Deserialize<List<Workflow>>(fileData);

RulesEngineDemoContext db = new RulesEngineDemoContext();
if (db.Database.EnsureCreated())
Expand Down
14 changes: 7 additions & 7 deletions demo/DemoApp/JSONDemo.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using RulesEngine.Models;
using System;
using System.Collections.Generic;
Expand All @@ -12,6 +10,8 @@

namespace DemoApp
{
using System.Text.Json;

public class JSONDemo
{
public void Run()
Expand All @@ -21,11 +21,11 @@ public void Run()
var orderInfo = "{\"totalOrders\": 5,\"recurringItems\": 2}";
var telemetryInfo = "{\"noOfVisitsPerMonth\": 10,\"percentageOfBuyingToVisit\": 15}";

var converter = new ExpandoObjectConverter();

dynamic input1 = JsonConvert.DeserializeObject<ExpandoObject>(basicInfo, converter);
dynamic input2 = JsonConvert.DeserializeObject<ExpandoObject>(orderInfo, converter);
dynamic input3 = JsonConvert.DeserializeObject<ExpandoObject>(telemetryInfo, converter);

dynamic input1 = JsonSerializer.Deserialize<ExpandoObject>(basicInfo);
dynamic input2 = JsonSerializer.Deserialize<ExpandoObject>(orderInfo);
dynamic input3 = JsonSerializer.Deserialize<ExpandoObject>(telemetryInfo);

var inputs = new dynamic[]
{
Expand All @@ -39,7 +39,7 @@ public void Run()
throw new Exception("Rules not found.");

var fileData = File.ReadAllText(files[0]);
var workflow = JsonConvert.DeserializeObject<List<Workflow>>(fileData);
var workflow = JsonSerializer.Deserialize<List<Workflow>>(fileData);

var bre = new RulesEngine.RulesEngine(workflow.ToArray(), null);

Expand Down
5 changes: 3 additions & 2 deletions demo/DemoApp/NestedInputDemo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using Newtonsoft.Json;
using RulesEngine.Extensions;
using RulesEngine.Models;
using System;
Expand All @@ -10,6 +9,8 @@

namespace DemoApp
{
using System.Text.Json;

internal class ListItem
{
public int Id { get; set; }
Expand Down Expand Up @@ -49,7 +50,7 @@ public void Run()
}

var fileData = File.ReadAllText(files[0]);
var Workflows = JsonConvert.DeserializeObject<List<Workflow>>(fileData);
var Workflows = JsonSerializer.Deserialize<List<Workflow>>(fileData);

var bre = new RulesEngine.RulesEngine(Workflows.ToArray(), null);
foreach (var workflow in Workflows)
Expand Down
Loading

0 comments on commit c4b108b

Please sign in to comment.