ForCtorParam MapFrom any expression#3169
ForCtorParam MapFrom any expression#3169jbogard merged 1 commit intoLuckyPennySoftware:masterfrom spydacarnage:master
Conversation
src/AutoMapper/ConstructorMap.cs
Outdated
| using System.Linq.Expressions; | ||
| using System.Reflection; | ||
| using AutoMapper.Execution; | ||
| using AutoMapper.Configuration; |
There was a problem hiding this comment.
Please revert changes to this file.
| @@ -32,8 +32,8 @@ public ProfileMap(IProfileConfiguration profile, IConfiguration configuration) | |||
| EnableNullPropagationForQueryMapping = profile.EnableNullPropagationForQueryMapping ?? configuration?.EnableNullPropagationForQueryMapping ?? false; | |||
There was a problem hiding this comment.
Please revert changes to this file.
src/AutoMapper/TypeMapFactory.cs
Outdated
| } | ||
| } | ||
| } | ||
| //if (!destinationType.IsAbstract()) |
src/AutoMapper/TypeMapFactory.cs
Outdated
| 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) |
| @@ -3,11 +3,41 @@ | |||
| using Shouldly; | |||
There was a problem hiding this comment.
Revert changes to this file.
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
That seems just copy pasted from TypeMapFactory.
There was a problem hiding this comment.
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?
| } | ||
| } | ||
|
|
||
| public bool CheckCtorParamName(string paramName) |
There was a problem hiding this comment.
This hides the meaning. Just expose the parameter name.
| { | ||
| var dest = Mapper.Map<Dest>(new Source("Success")); | ||
|
|
||
| dest.ShouldNotBeNull(); |
There was a problem hiding this comment.
Assert here what the property values should be. The same for the other test.
|
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. |
Fixes #3159.