Skip to content

Conversation

@spydacarnage
Copy link

@spydacarnage spydacarnage commented Jul 22, 2019

Fixes #3159.

using System.Linq.Expressions;
using System.Reflection;
using AutoMapper.Execution;
using AutoMapper.Configuration;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes to this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates made

Name = profile.ProfileName;
AllowNullCollections = profile.AllowNullCollections ?? configuration?.AllowNullCollections ?? false;
AllowNullDestinationValues = profile.AllowNullDestinationValues ?? configuration?.AllowNullDestinationValues ?? true;
EnableNullPropagationForQueryMapping = profile.EnableNullPropagationForQueryMapping ?? configuration?.EnableNullPropagationForQueryMapping ?? false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert changes to this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates made

}
}
}
//if (!destinationType.IsAbstract())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates made

private bool MapDestinationCtorToSource(TypeMap typeMap, ConstructorInfo destCtor, TypeDetails sourceTypeInfo, ProfileMap options)
{
var ctorParameters = destCtor.GetParameters();
//private bool MapDestinationCtorToSource(TypeMap typeMap, ConstructorInfo destCtor, TypeDetails sourceTypeInfo, ProfileMap options)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updates made

@@ -1,13 +1,43 @@
using System;
using System.Collections.Generic;
using Shouldly;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert changes to this file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apologies - that was a hangover from testing another reported issue simultaneously. Removed now.

return ctorMap.CanResolve;
}

private bool MapDestinationPropertyToSource(ProfileMap options, TypeDetails sourceTypeInfo, Type destType, Type destMemberType, string destMemberInfo, LinkedList<MemberInfo> members)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems just copy pasted from TypeMapFactory.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is, as it is needed in both locations. I wasn't sure what your policy on code sharing is.

I could remove it from both locations and add it as an instance method of ProfileMap, as that is shared between both locations? (I would also move MapDestinationCtorToSource to ProfileMap, too, as they are obviously linked).

Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, move them both.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved

}
}

public bool CheckCtorParamName(string paramName)
Copy link
Contributor

@lbargaoanu lbargaoanu Jul 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hides the meaning. Just expose the parameter name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update made

{
var dest = Mapper.Map<Dest>(new Source("Success"));

dest.ShouldNotBeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assert here what the property values should be. The same for the other test.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@lbargaoanu lbargaoanu changed the title ForCtorParam MapFrom any expression - second attempt ForCtorParam MapFrom any expression Jul 22, 2019
@lbargaoanu lbargaoanu added this to the v.Next milestone Jul 22, 2019
@jbogard jbogard merged commit f1becf5 into LuckyPennySoftware:master Jul 24, 2019
@lock
Copy link

lock bot commented Aug 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 Aug 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.

MapFrom doesn't resolve constructor parameters that have no matching source property

3 participants