-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
C# Expressions use Base Class Virtual Methodinfo #580
Comments
This will be fixed in linq2db, but ,aybe will also fail in other Linq Frameworks |
|
If I understand correctly, the following code: using System.Linq.Expressions;
using static System.Console;
using static System.Linq.Expressions.Expression;
using System.Linq.Dynamic.Core.Parser;
using System.Linq.Dynamic.Core;
Expression<Func<int?, string?>> expr = x => x.ToString();
WriteLine(
((MethodCallExpression)expr.Body).Method.DeclaringType
);
var selector = "ToString()";
var prm = Parameter(typeof(int?));
var parser = new ExpressionParser(new[] { prm }, selector, new object[] { }, ParsingConfig.Default);
var expr1 = parser.Parse(null);
WriteLine(
((MethodCallExpression)expr1).Method.DeclaringType
); prints out:
where both should have been the same. |
yes |
@jogibear9988 and @zspitz I did try to find the specific changes in source code in (https://github.com/zzzprojects/System.Linq.Dynamic/blob/archived/Src/System.Linq.Dynamic/DynamicLinq.cs) and this library. But finding a method and getting the base-type is done the same way. And the reason System.Nullable`1[System.Int32] is returned in that example code, is because this code line: And this is required. So can you please provide some more details on why / how this should be fixed in this project? |
Hello @jogibear9988, Can you please check my last comment? |
I think FindMethod should not return the Method it found, but the result of ".GetBaseDefinition()" of the Method it found. |
uses the topmost implementation of the virtual method
see pull #630 |
If you write a Expression where you call a Virtual Method, the C# Expression Parser uses the MethodInfo from the BaseClass where System.Dynamic.Linq uses the MethodInfo from the Derived Class.
see issue: linq2db/linq2db#3475
The text was updated successfully, but these errors were encountered: