We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hello.
When working with extensions methods, we encountered the following defects (in our opinion):
It is proposed to slightly improve the method FindMethod in a class MethodFinder (System.Linq.Dynamic.Core.Parser.SupportedMethods):
For example, instead (line 55):
// Try to solve with registered extension methods if (_parsingConfig.CustomTypeProvider.GetExtensionMethods().TryGetValue(type, out var methods)) { ... }
Do the following:
var methods = new List<MethodInfo>(); foreach (var t in SelfAndBaseTypes(type)) { // Try to solve with registered extension methods if (_parsingConfig.CustomTypeProvider.GetExtensionMethods().TryGetValue(t, out var methodsOfType)) { methods.AddRange(methodsOfType.Where(item => item.Name.Equals(methodName, StringComparison.OrdinalIgnoreCase) && !item.IsGenericMethod)); } } if (methods.Any()) { ... }
The text was updated successfully, but these errors were encountered:
Hi,
I have also run into above issue in my current project. I agree that MethodFinder only uses parameters to match a method and skips it's name.
You can test it by adding:
public static int IncrementMeAlso(this int values) { return values + 1; }
next to IncrementMe method in Utlis class of System.Linq.Dynamic.Core.Tests.Parser.DynamicLinqTypeTest. ExtensionMethod_NoParameter test will fail.
IncrementMe
Utlis
System.Linq.Dynamic.Core.Tests.Parser.DynamicLinqTypeTest
ExtensionMethod_NoParameter
Sorry, something went wrong.
+1 on this one, practically it turns extension methods into unusable at best, unpredictable at worst.
Hello @kriszek, thank you for this detailed description + solution.
I did update fix the code as suggested and updated unit-tests to verify the solution.
I'll merge the PR and a this fix will be included in next NuGet version.
StefH
No branches or pull requests
Hello.
When working with extensions methods, we encountered the following defects (in our opinion):
It is proposed to slightly improve the method FindMethod in a class MethodFinder (System.Linq.Dynamic.Core.Parser.SupportedMethods):
For example, instead (line 55):
Do the following:
The text was updated successfully, but these errors were encountered: