-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add support to specify ShouldMapMethod #2960
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
Conversation
src/AutoMapper/TypeDetails.cs
Outdated
private IEnumerable<MethodInfo> BuildPublicNoArgExtensionMethods(IEnumerable<MethodInfo> sourceExtensionMethodSearch, Func<MethodInfo, bool> shouldMapMethod) | ||
{ | ||
var explicitExtensionMethods = sourceExtensionMethodSearch.Where(method => method.GetParameters()[0].ParameterType == Type); | ||
var explicitExtensionMethods = sourceExtensionMethodSearch.Where(shouldMapMethod).Where(method => method.GetParameters()[0].ParameterType == Type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove all the filters inside the method and simply filter the input parameter when calling the method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sense!
namespace AutoMapper.UnitTests | ||
{ | ||
public class ShouldMapMethod : NonValidatingSpecBase | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, but the extension method case needs a test too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I'm gonna add it.
…ling BuildPublicNoArgExtensionMethods
Hi @jbogard, did you have a chance to look to this PR? Please let me know if anything is missing. Thanks in advance. |
Thank you very much @jbogard. Any chance to launch a pre-release version on nuget that include this change. |
@lbargaoanu Thank you. MyGet build worked. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Add support to specify ShouldMapMethod to determine which methods, of those that are eligible to be mapped (parameterless, public, and non-static or extension methods) should be mapped.
Fixed #2959