Farfetch / rules-framework

A generic framework that allows defining and evaluating rules for complex business scenarios.
MIT License
41 stars 8 forks source link

[Bug Report]: ArgumentNullException thrown when trying to build a rules engine with in-memory data source stored on IServiceCollection #141

Closed luispfgarces closed 1 year ago

luispfgarces commented 1 year ago

Prerequisites

Description

When using the built-in extensions to use the in-memory data source based on the rules stored on IServiceCollection, an ArgumentNullException is thrown. Sample bellow:

System.ArgumentNullException : Value cannot be null. (Parameter 'inMemoryRulesStorage')

Steps to reproduce

The following source code allows us to reproduce the issue:

var serviceProvider = new ServiceCollection()
    .AddInMemoryRulesDataSource<ContentTypes, ConditionTypes>(ServiceLifetime.Singleton)
    .BuildServiceProvider();

var rulesEngine = RulesEngineBuilder.CreateRulesEngine()
    .WithContentType<ContentTypes>()
    .WithConditionType<ConditionTypes>()
    .SetInMemoryDataSource(serviceProvider)
    .Build();

Expected behavior

The extension method for using the in-memory data source based on the IServiceCollection should be able to resolve an IInMemoryRulesStorage<TContentType, TConditionType>.

Actual behavior

An ArgumentNullException is thrown.

Rules Framework version

2.0.0