Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9d2dfd9
consider member value resolvers and value converters for source valid…
lbargaoanu Jun 29, 2022
29f1beb
simplify
lbargaoanu Jun 29, 2022
8552e2e
re-enable configuration only tests
lbargaoanu Jun 30, 2022
18c7f73
try to cover all cases
lbargaoanu Jul 1, 2022
704e5ba
cosmetic
lbargaoanu Jul 6, 2022
ba60290
polymorphic implementation for type converters
lbargaoanu Jul 6, 2022
7eff43f
remove ConstructDestinationUsingServiceLocator
lbargaoanu Jul 7, 2022
3c2ec11
simplify
lbargaoanu Jul 7, 2022
884e22a
remove TypeMap.AsProxy
lbargaoanu Jul 7, 2022
a2c4ba0
remove DestinationTypeToUse
lbargaoanu Jul 7, 2022
42ef755
code reuse
lbargaoanu Jul 7, 2022
821d4fa
add MemberMap.Resolver
lbargaoanu Jul 8, 2022
c38b3dc
code reuse
lbargaoanu Jul 8, 2022
ed3ac6e
Resolver.GetSourceMember
lbargaoanu Jul 8, 2022
99092f4
ClassValueResolver
lbargaoanu Jul 8, 2022
2fa05d6
FuncResolver
lbargaoanu Jul 8, 2022
ce51167
ExpressionResolver
lbargaoanu Jul 8, 2022
8ce0961
remove storage for CustomCtorExpression
lbargaoanu Jul 8, 2022
40cecce
remove storage for TypeMap.CustomMapExpression
lbargaoanu Jul 8, 2022
6cd3631
cosmetic
lbargaoanu Jul 8, 2022
854fa31
implement the convention based resolver in MemberMap
lbargaoanu Jul 9, 2022
1eab5f1
implement CanResolveValue in MemberMap
lbargaoanu Jul 9, 2022
787ae9d
cosmetic
lbargaoanu Jul 9, 2022
9b872ef
remove TypeMap.IsValid
lbargaoanu Jul 10, 2022
63aeef3
DestinationTypeOverride is considered separately
lbargaoanu Jul 10, 2022
c366182
cosmetic
lbargaoanu Jul 10, 2022
8d87e4e
MemberMapDetails
lbargaoanu Jul 10, 2022
20e379d
TypeMapDetails
lbargaoanu Jul 10, 2022
a1c02c7
cosmetic
lbargaoanu Jul 10, 2022
415c1d4
remove TypeMap._orderedPropertyMaps
lbargaoanu Jul 11, 2022
8b733b1
cosmetic
lbargaoanu Jul 11, 2022
999d65f
reuse the constructor map object
lbargaoanu Jul 12, 2022
79fd635
cosmetic
lbargaoanu Jul 12, 2022
449a50b
remove QueryMapperVisitor
lbargaoanu Jul 13, 2022
5b0cf17
hard code the map based projection mappers
lbargaoanu Jul 14, 2022
6fdc82b
IPojectionMapper.IsMatch(TypePair context)
lbargaoanu Jul 15, 2022
ddc934f
cosmetic
lbargaoanu Jul 15, 2022
798ebf2
constructor parameters default values with ProjectTo
lbargaoanu Jul 17, 2022
6024cf3
remove ResolutionContext.Options
lbargaoanu Jul 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove DestinationTypeToUse
  • Loading branch information
lbargaoanu committed Jul 7, 2022
commit a2c4ba02be39d866cea10ab9ff49bb47b0338242
4 changes: 2 additions & 2 deletions src/AutoMapper/Execution/TypeMapPlanBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public TypeMapPlanBuilder(IGlobalConfiguration configurationProvider, TypeMap ty
_configurationProvider = configurationProvider;
_typeMap = typeMap;
Source = Parameter(typeMap.SourceType, "source");
_initialDestination = Parameter(typeMap.DestinationTypeToUse, "destination");
_initialDestination = Parameter(typeMap.DestinationType, "destination");
_destination = Variable(_initialDestination.Type, "typeMapDestination");
}
public Type DestinationType => _destination.Type;
Expand Down Expand Up @@ -254,7 +254,7 @@ private Expression CheckReferencesCache(Expression valueBuilder)
{ CustomCtorExpression: LambdaExpression constructUsing } => constructUsing.ReplaceParameters(Source),
{ CustomCtorFunction: LambdaExpression constructUsingFunc } => constructUsingFunc.ReplaceParameters(Source, ContextParameter),
{ ConstructorMap: { CanResolve: true } constructorMap } => ConstructorMapping(constructorMap),
{ DestinationTypeToUse: { IsInterface: true } interfaceType } => Throw(Constant(new AutoMapperMappingException("Cannot create interface "+interfaceType, null, _typeMap)), interfaceType),
{ DestinationType: { IsInterface: true } interfaceType } => Throw(Constant(new AutoMapperMappingException("Cannot create interface "+interfaceType, null, _typeMap)), interfaceType),
_ => ObjectFactory.GenerateConstructorExpression(DestinationType)
};
private Expression ConstructorMapping(ConstructorMap constructorMap)
Expand Down
2 changes: 1 addition & 1 deletion src/AutoMapper/QueryableExtensions/ProjectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ IProjectionMapper GetProjectionMapper()
{ CustomCtorExpression: LambdaExpression ctorExpression } => (NewExpression)ctorExpression.ReplaceParameters(instanceParameter),
{ ConstructorMap: { CanResolve: true } constructorMap } =>
New(constructorMap.Ctor, constructorMap.CtorParams.Select(map => TryProjectMember(map) ?? Default(map.DestinationType))),
_ => New(typeMap.DestinationTypeToUse)
_ => New(typeMap.DestinationType)
};
}
private static AutoMapperMappingException CannotMap(MemberMap memberMap, Type sourceType) => new(
Expand Down
7 changes: 3 additions & 4 deletions src/AutoMapper/TypeMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public Type DestinationTypeOverride
_sealed = true;
}
}
public Type DestinationTypeToUse => DestinationTypeOverride ?? DestinationType;
public bool IncludeAllDerivedTypes { get; set; }
public MemberList ConfiguredMemberList { get; set; }
public IReadOnlyCollection<TypePair> IncludedDerivedTypes => _includedDerivedTypes.NullCheck();
Expand Down Expand Up @@ -133,9 +132,9 @@ public IEnumerable<MemberMap> MemberMaps
DisableConstructorValidation
|| CustomConstruction
|| ConstructorMapping
|| DestinationTypeToUse.IsAbstract
|| DestinationTypeToUse.IsGenericTypeDefinition
|| DestinationTypeToUse.IsValueType
|| DestinationType.IsAbstract
|| DestinationType.IsGenericTypeDefinition
|| DestinationType.IsValueType
|| TypeDetails.GetConstructors(DestinationType, Profile).Any(c => c.AllParametersOptional());
public MemberInfo[] DestinationSetters => DestinationTypeDetails.WriteAccessors;
public ConstructorParameters[] DestinationConstructors => DestinationTypeDetails.Constructors;
Expand Down
8 changes: 4 additions & 4 deletions src/UnitTests/CustomValidations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class When_using_custom_validation_for_convertusing_with_mappingfunction
private static void SetValidated(ValidationContext context)
{
if (context.TypeMap.SourceType == typeof(Source) &&
context.TypeMap.DestinationTypeToUse == typeof(Destination))
context.TypeMap.DestinationType == typeof(Destination))
{
_validated = true;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ public class When_using_custom_validation_for_convertusing_with_typeconvertertyp
private static void SetValidated(ValidationContext context)
{
if (context.TypeMap.SourceType == typeof(Source) &&
context.TypeMap.DestinationTypeToUse == typeof(Destination))
context.TypeMap.DestinationType == typeof(Destination))
{
_validated = true;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ public class When_using_custom_validation_for_convertusing_with_typeconverter_in
private static void SetValidated(ValidationContext context)
{
if (context.TypeMap.SourceType == typeof(Source) &&
context.TypeMap.DestinationTypeToUse == typeof(Destination))
context.TypeMap.DestinationType == typeof(Destination))
{
_validated = true;
}
Expand Down Expand Up @@ -206,7 +206,7 @@ public class When_using_custom_validation_for_convertusing_with_mappingexpressio
private static void SetValidated(ValidationContext context)
{
if (context.TypeMap.SourceType == typeof(Source) &&
context.TypeMap.DestinationTypeToUse == typeof(Destination))
context.TypeMap.DestinationType == typeof(Destination))
{
_validated = true;
}
Expand Down