Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

* Updated dependecies #394

Merged
merged 5 commits into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "4.7.1",
"version": "5.1.10",
"commands": [
"reportgenerator"
]
Expand Down
13 changes: 8 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "RulesEngine Codespace",
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0.201.7-3.1",
"image": "mcr.microsoft.com/vscode/devcontainers/dotnet:0-6.0",
"settings": {
"terminal.integrated.defaultProfile.linux": "pwsh"
"terminal.integrated.defaultProfile.linux": "bash"
},
"extensions": [
"eamodio.gitlens",
Expand All @@ -12,12 +12,15 @@
"cschleiden.vscode-github-actions",
"redhat.vscode-yaml",
"bierner.markdown-preview-github-styles",
"ban.spellright",
"jmrog.vscode-nuget-package-manager",
"coenraads.bracket-pair-colorizer",
"vscode-icons-team.vscode-icons",
"editorconfig.editorconfig"
"editorconfig.editorconfig",
"aliasadidev.nugetpackagemanagergui",
"formulahendry.dotnet-test-explorer"
],
"postCreateCommand": "dotnet restore RulesEngine.sln && dotnet build RulesEngine.sln --configuration Release --no-restore && dotnet test RulesEngine.sln --configuration Release --no-build --verbosity minimal",
"features": {
"powershell": "7.1"
},
}
// Built with ❤ by [Pipeline Foundation](https://pipeline.foundation)
49 changes: 14 additions & 35 deletions .github/workflows/dotnetcore-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,34 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
# extract branch name
- name: Extract branch name
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
id: extract_branch

# extract branch name on pull request
- name: Extract branch name on pull request
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF})" >> $GITHUB_ENV

# print branch name
- name: Get branch name
run: echo "The branch name is ${{ env.BRANCH_NAME }}"


- uses: actions/checkout@v3
- name: Setup .NET Core
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x

- name: Install minicover
run: dotnet tool install --global minicover --version 3.4.4

- name: Install dependencies
run: dotnet restore RulesEngine.sln

- name: Build
run: dotnet build RulesEngine.sln --configuration Release --no-restore

- name: Instrument
run: minicover instrument

- name: Test
run: dotnet test RulesEngine.sln --no-build --configuration Release --verbosity m

- name: Uninstrument
run: minicover uninstrument

- name: Report
run: minicover report --threshold 95
if: ${{ github.event_name == 'pull_request' }}
run: dotnet test RulesEngine.sln --collect:"XPlat Code Coverage" --no-build --configuration Release --verbosity m

- name: Generate Report
shell: pwsh
run: ./scripts/generate-coverage-report.ps1

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

- name: Report coveralls
run: minicover coverallsreport --repo-token ${{ secrets.COVERALLS_TOKEN }} --branch ${{ env.BRANCH_NAME }}
- name: Coveralls GitHub Action
uses: coverallsapp/[email protected]
if: ${{ github.event_name == 'push' }}
with:
github-token: ${{ secrets.COVERALLS_TOKEN }}
path-to-lcov: ./coveragereport/lcov.info
30 changes: 30 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@

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

## [4.0.0]
- RulesEngine is now available in both dotnet 6 and netstandard 2.0
- Dependency on ILogger, MemoryCache have been removed
- Obsolete Properties and Methods have been removed
### Breaking Changes
- ILogger has been removed from RulesEngine and all its constructors
```diff
- RulesEngine(string[] jsonConfig, ILogger logger = null, ReSettings reSettings = null)
+ RulesEngine(string[] jsonConfig, ReSettings reSettings = null)

- RulesEngine(Workflow[] Workflows, ILogger logger = null, ReSettings reSettings = null)
+ RulesEngine(Workflow[] Workflows, ReSettings reSettings = null)

- RulesEngine(ILogger logger = null, ReSettings reSettings = null)
+ RulesEngine(ReSettings reSettings = null)
```
- Obsolete methods and properties have been removed, from the follow models:-
- RuleResultTree
- `ToResultTreeMessages()` has been removed from `RuleResultTree` model
- `GetMessages()` has been removed from `RuleResultTree` model
- `RuleEvaluatedParams` has been removed from `RuleResultTree` model, Please use `Inputs` instead

- Workflow
- `WorkflowRulesToInject` has been removed, Please use `WorkflowsToInject` instead
- `ErrorType` has been removed from `Rule`

- Resettings
- `EnableLocalParams` has been removed from `ReSettings`, Please use `EnableScopedParams` instead


## [3.5.0]
- `EvaluateRule` action now support custom inputs and filtered inputs
- Added `ContainsWorkflow` method in RulesEngine (by @okolobaxa)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/RulesEngineBenchmark/RulesEngineBenchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.1" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.2" />
<!--<PackageReference Include="RulesEngine" Version="3.0.2" />-->
</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,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -7,8 +7,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.9" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion demo/DemoApp.EFDataExample/RulesEngineContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
v => JsonSerializer.Deserialize<RuleActions>(v, serializationOptions));

entity.Ignore(b => b.WorkflowsToInject);
entity.Ignore(b => b.WorkflowRulesToInject);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0",
"version": "6.0.0",
"rollForward": "latestFeature",
"allowPrerelease": false
}
Expand Down
16 changes: 16 additions & 0 deletions scripts/check-coverage.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
param(
[Parameter(Mandatory=$true)][string] $reportPath,
[Parameter(Mandatory=$true)][decimal] $threshold
)


[XML]$report = Get-Content $reportPath;
[decimal]$coverage = [decimal]$report.coverage.'line-rate' * 100;

if ($coverage -lt $threshold) {
Write-Error "Coverage($coverage) is less than $threshold percent"
exit 1
}
else{
Write-Host "Coverage($coverage) is more than $threshold percent"
}
2 changes: 2 additions & 0 deletions scripts/generate-coverage-report.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dotnet tool restore
dotnet reportgenerator "-reports:**/coverage.cobertura.xml" "-targetdir:coveragereport" -reporttypes:"Html;lcov;Cobertura"
45 changes: 0 additions & 45 deletions src/RulesEngine/HelperFunctions/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,50 +74,5 @@ internal static string GetExceptionMessage(string message,ReSettings reSettings)
{
return reSettings.IgnoreException ? "" : message;
}

/// <summary>
/// To the result tree error messages
/// </summary>
/// <param name="ruleResultTree">ruleResultTree</param>
/// <param name="ruleResultMessage">ruleResultMessage</param>
[Obsolete]
internal static void ToResultTreeMessages(RuleResultTree ruleResultTree, ref RuleResultMessage ruleResultMessage)
{
if (ruleResultTree.ChildResults != null)
{
GetChildRuleMessages(ruleResultTree.ChildResults, ref ruleResultMessage);
}
else
{
if (!ruleResultTree.IsSuccess)
{
string errMsg = ruleResultTree.Rule.ErrorMessage;
errMsg = string.IsNullOrEmpty(errMsg) ? $"Error message is not configured for {ruleResultTree.Rule.RuleName}" : errMsg;

if (ruleResultTree.Rule.ErrorType == ErrorType.Error && !ruleResultMessage.ErrorMessages.Contains(errMsg))
{
ruleResultMessage.ErrorMessages.Add(errMsg);
}
else if (ruleResultTree.Rule.ErrorType == ErrorType.Warning && !ruleResultMessage.WarningMessages.Contains(errMsg))
{
ruleResultMessage.WarningMessages.Add(errMsg);
}
}
}
}

/// <summary>
/// To get the child error message recursively
/// </summary>
/// <param name="childResultTree">childResultTree</param>
/// <param name="ruleResultMessage">ruleResultMessage</param>
[Obsolete]
private static void GetChildRuleMessages(IEnumerable<RuleResultTree> childResultTree, ref RuleResultMessage ruleResultMessage)
{
foreach (var item in childResultTree)
{
ToResultTreeMessages(item, ref ruleResultMessage);
}
}
}
}
10 changes: 0 additions & 10 deletions src/RulesEngine/Models/ReSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ public class ReSettings
/// Sets the mode for Nested rule execution, Default: All
/// </summary>
public NestedRuleExecutionMode NestedRuleExecutionMode { get; set; } = NestedRuleExecutionMode.All;

/// <summary>
/// Enables Local params for rules
/// </summary>
[Obsolete("Use 'EnableScopedParams' instead. This will be removed in next major version")]
public bool EnableLocalParams {
get { return EnableScopedParams; }
set { EnableScopedParams = value; }
}

public MemCacheConfig CacheConfig { get; set; }
}

Expand Down
12 changes: 0 additions & 12 deletions src/RulesEngine/Models/Rule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;

Expand Down Expand Up @@ -34,20 +33,9 @@ public class Rule
/// </summary>
public bool Enabled { get; set; } = true;

[Obsolete("will be removed in next major version")]
[JsonConverter(typeof(StringEnumConverter))]
public ErrorType ErrorType { get; set; } = ErrorType.Warning;

[JsonConverter(typeof(StringEnumConverter))]
public RuleExpressionType RuleExpressionType { get; set; } = RuleExpressionType.LambdaExpression;

[Obsolete("WorkflowRulesToInject is deprecated. Use WorkflowsToInject instead.")]
public IEnumerable<string> WorkflowRulesToInject {
get { return WorkflowsToInject; }
set { WorkflowsToInject = value; }
}
public IEnumerable<string> WorkflowsToInject { get; set; }

public IEnumerable<Rule> Rules { get; set; }
public IEnumerable<ScopedParam> LocalParams { get; set; }
public string Expression { get; set; }
Expand Down
23 changes: 0 additions & 23 deletions src/RulesEngine/Models/RuleResultTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,29 +50,6 @@ public class RuleResultTree
/// </summary>
public string ExceptionMessage { get; set; }

/// <summary>
/// Gets or sets the rule evaluated parameters.
/// </summary>
/// <value>
/// The rule evaluated parameters.
/// </value>
[Obsolete("Use `Inputs` field to get details of all input, localParams and globalParams")]
public IEnumerable<RuleParameter> RuleEvaluatedParams { get; set; }

/// <summary>
/// This method will return all the error and warning messages to caller
/// </summary>
/// <returns>RuleResultMessage</returns>
[ExcludeFromCodeCoverage]
[Obsolete("will be removed in next major version")]
public RuleResultMessage GetMessages()
{
var ruleResultMessage = new RuleResultMessage();

Helpers.ToResultTreeMessages(this, ref ruleResultMessage);

return ruleResultMessage;
}
}

/// <summary>
Expand Down
8 changes: 0 additions & 8 deletions src/RulesEngine/RuleCompiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,6 @@ private RuleFunc<RuleResultTree> GetWrappedRuleFunc(Rule rule, RuleFunc<RuleResu

var extendedInputs = ruleParams.Concat(scopedParams);
var result = ruleFunc(extendedInputs.ToArray());
// To be removed in next major release
#pragma warning disable CS0618 // Type or member is obsolete
if(result.RuleEvaluatedParams == null)
{
result.RuleEvaluatedParams = scopedParams;
}
#pragma warning restore CS0618 // Type or member is obsolete

return result;
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/RulesEngine/RulesEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ private List<RuleResultTree> ExecuteAllRuleByWorkflow(string workflowName, RuleP

private string GetCompiledRulesKey(string workflowName, RuleParameter[] ruleParams)
{
var ruleParamsHash = string.Join("-", ruleParams.Select(c => $"{c.Name}_{c.Type.Name}")).GetHashCode();
var key = $"{workflowName}-" + ruleParamsHash;
var ruleParamsKey = string.Join("-", ruleParams.Select(c => $"{c.Name}_{c.Type.Name}"));
var key = $"{workflowName}-" + ruleParamsKey;
return key;
}

Expand Down
8 changes: 4 additions & 4 deletions src/RulesEngine/RulesEngine.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<Version>4.0.0-preview.1</Version>
<TargetFrameworks>net6.0;netstandard2.0</TargetFrameworks>
<Version>4.0.0</Version>
<Copyright>Copyright (c) Microsoft Corporation.</Copyright>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/microsoft/RulesEngine</PackageProjectUrl>
Expand Down Expand Up @@ -31,8 +31,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="FastExpressionCompiler" Version="3.2.2" />
<PackageReference Include="FluentValidation" Version="11.0.1" />
<PackageReference Include="FastExpressionCompiler" Version="3.3.3" />
<PackageReference Include="FluentValidation" Version="11.2.2" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Linq" Version="4.3.0" />
Expand Down
Loading