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

System.Linq.Dynamic.Core failure when parsing rules #96

Open
dbelcham opened this issue Jan 9, 2025 · 6 comments
Open

System.Linq.Dynamic.Core failure when parsing rules #96

dbelcham opened this issue Jan 9, 2025 · 6 comments

Comments

@dbelcham
Copy link

dbelcham commented Jan 9, 2025

I'm getting the following error when running rules.

Exception while parsing expression application.Amount >= 5000 AND application.Amount <= 55000 - Method not found: 'Void System.Linq.Dynamic.Core.Parser.ExpressionParser..ctor(System.Linq.Expressions.ParameterExpression[], System.String, System.Object[], System.Linq.Dynamic.Core.ParsingConfig)'.

I am referencing the following

<PackageReference Include="RulesEngineEx" Version="[6.0.6, 7)" />

which pulls in (as of today) System.Linq.Dynamic.Core version 1.5.1 as a transitive dependency.

This was also a problem in the original codebase and mention of it can be found here and here

I cannot find an issue or code commit in this repo that addresses those original comments/issues.

I did have this working (with the pre-fork library) when the transitive dependency was picking up System.Linq.Dynamic.Core version 1.4.5. Testing both the pre-fork and this library with 1.5.1 results in both throwing the same error. Looking at the code for the dynamic linq stuff, it looks like they might have introduced a breaking change which is causing all of this.

What is odd to me is that the RulesEngine.csproj references a pinned version of that library at 1.4.3, but the Nuget definition is showing System.Linq.Dynamic.Core (>= 1.4.6). What is in the csproj would point at a working version of the Linq library, but nuget is allowing for 1.5.1 to be picked up. I can't find where you have defined the creation of the nupkg in any of the pipeline files so I'm not sure how that difference is being created.

@asulwer
Copy link
Owner

asulwer commented Jan 10, 2025

i modified the basic example to reflect your issue and it works fine.

Expression = "count >= 0 AND count <= 3"

i am making an assumption here that you are calling the wrong method signature for ExecuteAllRulesAsync.

compare the original BasicDemo to new Basic example. the method signatures that use params as a parameter are the original methods with CancellationToken added to them

@dbelcham if my comment has helped please let me know so i can close this ticket

@asulwer asulwer closed this as completed Jan 17, 2025
@Matthias-Meyer
Copy link

I'm afraid this is not solved. Apparently the authors of System.Linq.Dynamic.Core made an incompatible change by adding an optional parameter to the ctor of System.Linq.Dynamic.Core.Parser.ExpressionParser in V. 1.5.0:
https://github.com/zzzprojects/System.Linq.Dynamic.Core/blob/v1.5.0/src/System.Linq.Dynamic.Core/Parser/ExpressionParser.cs

@asulwer
Copy link
Owner

asulwer commented Jan 29, 2025

@Matthias-Meyer the reported issue is improper use of RulesEngine. i tested against the current version and examples and see no issue

@Matthias-Meyer
Copy link

@asulwer I don't think so, see:
zzzprojects/System.Linq.Dynamic.Core#881
The fix restores the compatibility by adding another ctor without optional parameters.

@ShaylenUkbush
Copy link

ShaylenUkbush commented Feb 3, 2025

@Matthias-Meyer Are you on the latest version and is it working?, currently on version 1.6.0.1 and still experiencing the same issue.

@asulwer
Copy link
Owner

asulwer commented Feb 3, 2025

@Matthias-Meyer

two constructors exist, i see that now. missing and set and no longer optional. RulesEngine uses the first constructor which sets that parameter to false.

regardless, i altered the two Basic demos to reflect the originally posted issue and the issue is not appearing. what am i missing?

@asulwer asulwer reopened this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants