Skip to content

Conversation

bfcamara
Copy link
Contributor

@bfcamara bfcamara commented Jan 22, 2019

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

@dnfclas
Copy link

dnfclas commented Jan 22, 2019

CLA assistant check
All CLA requirements met.

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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
{
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@bfcamara
Copy link
Contributor Author

Hi @jbogard, did you have a chance to look to this PR? Please let me know if anything is missing.

Thanks in advance.

@jbogard jbogard merged commit 82417a5 into LuckyPennySoftware:master Jan 31, 2019
@bfcamara
Copy link
Contributor Author

Thank you very much @jbogard. Any chance to launch a pre-release version on nuget that include this change.

@lbargaoanu
Copy link
Contributor

@bfcamara Try the MyGet build.

@bfcamara
Copy link
Contributor Author

@lbargaoanu Thank you. MyGet build worked.

@bfcamara bfcamara deleted the ShouldMapMethod branch January 31, 2019 17:24
@jbogard jbogard added this to the v.next milestone Apr 23, 2019
@lock
Copy link

lock bot commented May 24, 2019

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.

@lock lock bot locked as resolved and limited conversation to collaborators May 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support to skip scanning some methods when building TypeDetails

4 participants