Skip to content
Closed
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
18 changes: 0 additions & 18 deletions .github/workflows/dotnet-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,27 +145,9 @@ jobs:
- name: Clean
run: dotnet clean -c Release

- name: Replace Rules.Framework package references w/ project references
run: |
dotnet remove src/Rules.Framework.Providers.InMemory/Rules.Framework.Providers.InMemory.csproj package Rules.Framework
dotnet remove src/Rules.Framework.Providers.MongoDb/Rules.Framework.Providers.MongoDb.csproj package Rules.Framework
dotnet remove src/Rules.Framework.WebUI/Rules.Framework.WebUI.csproj package Rules.Framework
dotnet add src/Rules.Framework.Providers.InMemory/Rules.Framework.Providers.InMemory.csproj reference src/Rules.Framework/Rules.Framework.csproj
dotnet add src/Rules.Framework.Providers.MongoDb/Rules.Framework.Providers.MongoDb.csproj reference src/Rules.Framework/Rules.Framework.csproj
dotnet add src/Rules.Framework.WebUI/Rules.Framework.WebUI.csproj reference src/Rules.Framework/Rules.Framework.csproj

- name: Clear Nuget locals
run: dotnet nuget locals all --clear

- name: Restore dependencies w/ Rules.Framework project reference
run: dotnet restore

- name: Build w/ Rules.Framework project reference
run: dotnet build --no-restore -c Release

- name: Test w/ Rules.Framework project reference (no coverage)
run: dotnet test --no-build --verbosity normal -m:1 -c Release

- name: Delete build tag if exists
uses: dev-drprasad/delete-tag-and-release@v0.2.0
continue-on-error: true
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/dotnet-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ jobs:
- name: Pack Rules.Framework.Providers.MongoDb
run: dotnet pack src/Rules.Framework.Providers.MongoDb/Rules.Framework.Providers.MongoDb.csproj --include-symbols -c Release /p:Version=$BUILD_VERSION

- name: Pack Rules.Framework.Providers.InMemory
run: dotnet pack src/Rules.Framework.Providers.InMemory/Rules.Framework.Providers.InMemory.csproj --include-symbols -c Release /p:Version=$BUILD_VERSION

- name: Pack Rules.Framework.WebUI
run: dotnet pack src/Rules.Framework.WebUI/Rules.Framework.WebUI.csproj --include-symbols -c Release /p:Version=$BUILD_VERSION

Expand Down
7 changes: 0 additions & 7 deletions rules-framework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.Providers.M
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.Providers.MongoDb.Tests", "tests\Rules.Framework.Providers.MongoDb.Tests\Rules.Framework.Providers.MongoDb.Tests.csproj", "{C2957B7C-D601-4850-BCCE-D9AEF07225AB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.Providers.InMemory", "src\Rules.Framework.Providers.InMemory\Rules.Framework.Providers.InMemory.csproj", "{D3A17A64-CC74-4EA0-95EA-9E141913BF70}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.IntegrationTests.Common", "tests\Rules.Framework.IntegrationTests.Common\Rules.Framework.IntegrationTests.Common.csproj", "{7C04ECEF-6504-453D-ABD8-FD3D5A2CF7F6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Rules.Framework.Providers.InMemory.IntegrationTests", "tests\Rules.Framework.Providers.InMemory.IntegrationTests\Rules.Framework.Providers.InMemory.IntegrationTests.csproj", "{69BBA04D-116C-48EA-A8FD-ECC8CA0D57BE}"
Expand Down Expand Up @@ -72,10 +70,6 @@ Global
{C2957B7C-D601-4850-BCCE-D9AEF07225AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C2957B7C-D601-4850-BCCE-D9AEF07225AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C2957B7C-D601-4850-BCCE-D9AEF07225AB}.Release|Any CPU.Build.0 = Release|Any CPU
{D3A17A64-CC74-4EA0-95EA-9E141913BF70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D3A17A64-CC74-4EA0-95EA-9E141913BF70}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D3A17A64-CC74-4EA0-95EA-9E141913BF70}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D3A17A64-CC74-4EA0-95EA-9E141913BF70}.Release|Any CPU.Build.0 = Release|Any CPU
{7C04ECEF-6504-453D-ABD8-FD3D5A2CF7F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C04ECEF-6504-453D-ABD8-FD3D5A2CF7F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C04ECEF-6504-453D-ABD8-FD3D5A2CF7F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -115,7 +109,6 @@ Global
{460130DF-2360-494C-BB6F-BD87B033DF9D} = {AEE746EC-CEAA-4892-8C29-0CAAB97A23A8}
{8E14BC18-583F-43EF-99CF-08932D6303A0} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{C2957B7C-D601-4850-BCCE-D9AEF07225AB} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{D3A17A64-CC74-4EA0-95EA-9E141913BF70} = {AEE746EC-CEAA-4892-8C29-0CAAB97A23A8}
{7C04ECEF-6504-453D-ABD8-FD3D5A2CF7F6} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{69BBA04D-116C-48EA-A8FD-ECC8CA0D57BE} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
{BB319C5B-9BF5-4DDB-B522-CFC64D7272C4} = {74E24C97-8EE4-4B69-AECD-4765FD2C751F}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Rules.Framework.Providers.InMemory\Rules.Framework.Providers.InMemory.csproj" />
<ProjectReference Include="..\..\src\Rules.Framework\Rules.Framework.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Rules.Framework.Providers.InMemory\Rules.Framework.Providers.InMemory.csproj" />
<ProjectReference Include="..\..\src\Rules.Framework.WebUI\Rules.Framework.WebUI.csproj" />
</ItemGroup>

Expand Down
5 changes: 0 additions & 5 deletions src/Rules.Framework.Providers.InMemory/AssemblyMetadata.cs

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
</PackageReference>
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="MongoDB.Driver" Version="2.13.1" />
<PackageReference Include="Rules.Framework" Version="1.7.5" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Rules.Framework\Rules.Framework.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Rules.Framework.WebUI/Rules.Framework.WebUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Rules.Framework" Version="1.7.5" />
<ProjectReference Include="..\Rules.Framework\Rules.Framework.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/Rules.Framework/AssemblyMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

[assembly: InternalsVisibleTo("Rules.Framework.Tests")]
[assembly: InternalsVisibleTo("Rules.Framework.IntegrationTests")]
[assembly: InternalsVisibleTo("Rules.Framework.Providers.InMemory.Tests")]
[assembly: InternalsVisibleTo("Rules.Framework.Providers.InMemory.IntegrationTests")]
[assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")]
7 changes: 7 additions & 0 deletions src/Rules.Framework/IRulesEngineOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Rules.Framework
{
using System;
using System.Collections.Generic;
using Rules.Framework.Core;

Expand All @@ -22,6 +23,12 @@ public interface IRulesEngineOptions
/// <summary>
/// Gets the priority criteria to untie when multiples rules are matched.
/// </summary>
[Obsolete("This property has a typo and has been replaced by PriorityCriteria.")]
public PriorityCriterias PriotityCriteria { get; }

/// <summary>
/// Gets the priority criteria to untie when multiples rules are matched.
/// </summary>
public PriorityCriterias PriorityCriteria { get; }
}
}
6 changes: 4 additions & 2 deletions src/Rules.Framework/Rules.Framework.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>netstandard2.0</TargetFramework>
Expand All @@ -25,11 +25,12 @@
</PropertyGroup>

<ItemGroup>
<None Include="..\..\LICENSE.md">
<None Include="..\..\LICENSE.md" >
<Pack>True</Pack>
<PackagePath></PackagePath>
</None>
</ItemGroup>


<ItemGroup>
<PackageReference Include="FluentValidation" Version="10.3.6" />
Expand All @@ -41,5 +42,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.1.1" />
</ItemGroup>
</Project>
13 changes: 4 additions & 9 deletions src/Rules.Framework/RulesEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Task<RuleOperationResult> AddRuleAsync(Rule<TContentType, TConditionType>
/// <returns>Rules engine priority criterias</returns>
public PriorityCriterias GetPriorityCriteria()
{
return this.rulesEngineOptions.PriotityCriteria;
return this.rulesEngineOptions.PriorityCriteria;
}

/// <summary>
Expand Down Expand Up @@ -128,8 +128,8 @@ public Task<IEnumerable<Rule<TContentType, TConditionType>>> MatchManyAsync(TCon
MatchMode = MatchModes.Exact,
};

var dateBegin = matchDateTime.Date;
var dateEnd = matchDateTime.Date.AddDays(1);
var dateBegin = matchDateTime;
var dateEnd = matchDateTime;

return this.MatchAsync(contentType, dateBegin, dateEnd, conditions, evaluationOptions);
}
Expand Down Expand Up @@ -203,11 +203,6 @@ public async Task<IEnumerable<Rule<TContentType, TConditionType>>> SearchAsync(S
MatchMode = MatchModes.Search,
};

if (dateBegin == dateEnd)
{
dateEnd = dateBegin.AddDays(1);
}

return await this.MatchAsync(searchArgs.ContentType, dateBegin, dateEnd, searchArgs.Conditions, evaluationOptions).ConfigureAwait(false);
}

Expand Down Expand Up @@ -372,7 +367,7 @@ private async Task<IEnumerable<Rule<TContentType, TConditionType>>> MatchAsync(

private Rule<TContentType, TConditionType> SelectRuleByPriorityCriteria(IEnumerable<Rule<TContentType, TConditionType>> rules)
{
return this.rulesEngineOptions.PriotityCriteria == PriorityCriterias.BottommostRuleWins
return this.rulesEngineOptions.PriorityCriteria == PriorityCriterias.BottommostRuleWins
? rules.OrderByDescending(r => r.Priority).First()
: rules.OrderBy(r => r.Priority).First();
}
Expand Down
9 changes: 8 additions & 1 deletion src/Rules.Framework/RulesEngineOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Rules.Framework
{
using System;
using System.Collections.Generic;
using System.Linq;
using Rules.Framework.Core;
Expand Down Expand Up @@ -31,7 +32,7 @@ public static RulesEngineOptions NewWithDefaults()
RulesEngineOptions rulesEngineOptions = new RulesEngineOptions
{
MissingConditionBehavior = MissingConditionBehaviors.UseDataTypeDefault,
PriotityCriteria = PriorityCriterias.TopmostRuleWins
PriorityCriteria = PriorityCriterias.TopmostRuleWins
};

rulesEngineOptions.DataTypeDefaults[DataTypes.Boolean] = default(bool);
Expand Down Expand Up @@ -61,6 +62,12 @@ public static RulesEngineOptions NewWithDefaults()
/// <summary>
/// Gets or sets the priority criteria to untie when multiples rules are matched.
/// </summary>
[Obsolete("This property has a typo and has been replaced by PriorityCriteria.")]
public PriorityCriterias PriotityCriteria { get; set; }

/// <summary>
/// Gets or sets the priority criteria to untie when multiples rules are matched.
/// </summary>
public PriorityCriterias PriorityCriteria { get; set; }
}
}
28 changes: 15 additions & 13 deletions tests/Rules.Framework.IntegrationTests/RulesFromJsonFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ public async Task<IRulesDataSource<TContentType, TConditionType>> FromJsonFileAs
{
JsonContentSerializationProvider<TContentType> serializationProvider = new JsonContentSerializationProvider<TContentType>();

using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
using (StreamReader streamReader = new StreamReader(fileStream))
using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
using (var streamReader = new StreamReader(fileStream))
{
string contents = await streamReader.ReadToEndAsync();
IEnumerable<RuleDataModel> ruleDataModels = await Task.Run(() => JsonConvert.DeserializeObject<IEnumerable<RuleDataModel>>(contents));
var ruleDataModels = await Task.Run(() => JsonConvert.DeserializeObject<IEnumerable<RuleDataModel>>(contents));

List<Rule<TContentType, TConditionType>> rules = new List<Rule<TContentType, TConditionType>>(ruleDataModels.Count());
foreach (RuleDataModel ruleDataModel in ruleDataModels)
var rules = new List<Rule<TContentType, TConditionType>>(ruleDataModels.Count());
foreach (var ruleDataModel in ruleDataModels)
{
TContentType contentType = GetContentType<TContentType>(ruleDataModel.ContentTypeCode);
var contentType = GetContentType<TContentType>(ruleDataModel.ContentTypeCode);

IRuleBuilder<TContentType, TConditionType> ruleBuilder = RuleBuilder.NewRule<TContentType, TConditionType>()
var ruleBuilder = RuleBuilder.NewRule<TContentType, TConditionType>()
.WithName(ruleDataModel.Name)
.WithDatesInterval(ruleDataModel.DateBegin, ruleDataModel.DateEnd);

Expand All @@ -51,7 +51,7 @@ public async Task<IRulesDataSource<TContentType, TConditionType>> FromJsonFileAs
ruleBuilder.WithContentContainer(new ContentContainer<TContentType>(contentType, (t) => RulesFromJsonFile.Parse(ruleDataModel.Content, t)));
}

RuleBuilderResult<TContentType, TConditionType> ruleBuilderResult = ruleBuilder.Build();
var ruleBuilderResult = ruleBuilder.Build();

if (ruleBuilderResult.IsSuccess)
{
Expand Down Expand Up @@ -80,14 +80,15 @@ private static object Parse(string value, Type type)

private IConditionNode<TConditionType> ConvertConditionNode<TConditionType>(IConditionNodeBuilder<TConditionType> conditionNodeBuilder, ConditionNodeDataModel conditionNodeDataModel)
{
LogicalOperators logicalOperator = RulesFromJsonFile.Parse<LogicalOperators>(conditionNodeDataModel.LogicalOperator);
var logicalOperator = RulesFromJsonFile.Parse<LogicalOperators>(conditionNodeDataModel.LogicalOperator);

if (logicalOperator == LogicalOperators.Eval)
{
return this.CreateValueConditionNode<TConditionType>(conditionNodeBuilder, conditionNodeDataModel);
}
else
{
IComposedConditionNodeBuilder<TConditionType> composedConditionNodeBuilder = conditionNodeBuilder.AsComposed()
var composedConditionNodeBuilder = conditionNodeBuilder.AsComposed()
.WithLogicalOperator(logicalOperator);

foreach (ConditionNodeDataModel child in conditionNodeDataModel.ChildConditionNodes)
Expand All @@ -101,9 +102,10 @@ private IConditionNode<TConditionType> ConvertConditionNode<TConditionType>(ICon

private IConditionNode<TConditionType> CreateValueConditionNode<TConditionType>(IConditionNodeBuilder<TConditionType> conditionNodeBuilder, ConditionNodeDataModel conditionNodeDataModel)
{
DataTypes dataType = RulesFromJsonFile.Parse<DataTypes>(conditionNodeDataModel.DataType);
TConditionType integrationTestsConditionType = RulesFromJsonFile.Parse<TConditionType>(conditionNodeDataModel.ConditionType);
Operators @operator = RulesFromJsonFile.Parse<Operators>(conditionNodeDataModel.Operator);
var dataType = RulesFromJsonFile.Parse<DataTypes>(conditionNodeDataModel.DataType);
var integrationTestsConditionType = RulesFromJsonFile.Parse<TConditionType>(conditionNodeDataModel.ConditionType);
var @operator = RulesFromJsonFile.Parse<Operators>(conditionNodeDataModel.Operator);

switch (dataType)
{
case DataTypes.Integer:
Expand Down
Loading