-
-
Notifications
You must be signed in to change notification settings - Fork 384
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
Throw error when registering multiple times the same delegate #157
Comments
We have changed some internal code on how functions are interpreted, inside #138 or other related PRs. |
Within our framework, we use a lot of generic implementation, so I tried to simplify a repro of our implementation. I have added the repro project. If you run the tests, you can see two tests, one is failing failing, the failing one is exactly our current use cases. The tests becomes green switching back to V2.4.1. While reproducing the issue, I noticed that our code sets twice the same types and function. |
@knoxi thanks for the investigation. I suspect the double registration is the issue: in version 2.4.1, calling |
yes, with that explanation it makes now absolutely sense why we are running into that issue. Thanks! |
@knoxi I wouldn't close the issue just yet, I still want to investigate if that's actually the issue :) Also, we should detect if the same function is registered twice to prevent this from happening. |
It was possible to register the same delegate multiple times; that has now been fixed, thanks for the report! In your particular case however, you're registering two delegates that are in fact the same, but are built twice via We should throw an @davideicardi in private static MethodData[] FindBestMethod(IEnumerable<MethodData> methods, Expression[] args)
{
var applicable = methods.
Where(m => CheckIfMethodIsApplicableAndPrepareIt(m, args)).
ToArray();
if (applicable.Length > 1)
{
// can return an empty array; the ambiguity is lost to the caller
return applicable.
Where(m => applicable.All(n => m == n || MethodHasPriority(args, m, n))).
ToArray();
}
return applicable;
} |
Thank you @metoule for the investigation and fix! In my opinion it is not a bit issue for now, it can be solved by the caller. |
Closed by #158 |
After upgrading from V2.4.1 to a newer version, I'm receiving an error
DynamicExpresso.Exceptions.ParseException: 'Argument list incompatible with delegate expression (at index 0).
I have not seen any breaking changes in the release notes.The code I'm trying to parse:
The text was updated successfully, but these errors were encountered: