Skip to content

Commit

Permalink
Supporting AutoMapper v12. (#147)
Browse files Browse the repository at this point in the history
  • Loading branch information
BlaiseD authored Oct 1, 2022
1 parent 8817161 commit 5309cfa
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AutoMapper" Version="[11.0.0,12.0.0)" />
<PackageReference Include="AutoMapper" Version="[12.0.0,13.0.0)" />
<PackageReference Include="MinVer" Version="2.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ private static void DoAddTypeMappings(this Dictionary<Type, Type> typeMappings,
private static Type GetSourceMemberType(this PropertyMap propertyMap)
=> propertyMap.CustomMapExpression != null
? propertyMap.CustomMapExpression.ReturnType
: propertyMap.SourceMember.GetMemberType();
: propertyMap.SourceMembers.Last().GetMemberType();

private static void FindChildPropertyTypeMaps(this Dictionary<Type, Type> typeMappings, IConfigurationProvider ConfigurationProvider, Type source, Type dest)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ namespace AutoMapper.Extensions.ExpressionMapping

internal static class ReflectionExtensions
{
public static object GetDefaultValue(this ParameterInfo parameter)
=> ReflectionHelper.GetDefaultValue(parameter);

public static object MapMember(this ResolutionContext context, MemberInfo member, object value, object destination = null)
=> ReflectionHelper.MapMember(context, member, value, destination);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ private MemberBinding DoBind(MemberInfo sourceMember, Expression initial, Expres
private MemberInfo GetSourceMember(PropertyMap propertyMap)
=> propertyMap.CustomMapExpression != null
? propertyMap.CustomMapExpression.GetMemberExpression()?.Member
: propertyMap.SourceMember;
: propertyMap.SourceMembers.Last();

private MemberInfo GetParentMember(PropertyMap propertyMap)
=> propertyMap.IncludedMember?.ProjectToCustomSource != null
Expand Down Expand Up @@ -717,10 +717,6 @@ TypeMap GetTypeMap() => BothTypesAreAnonymous()
{
var propertyMap = typeMap.GetMemberMapByDestinationProperty(sourceFullName);
var sourceMemberInfo = typeSource.GetFieldOrProperty(propertyMap.GetDestinationName());
if (propertyMap.ValueResolverConfig != null)
{
throw new InvalidOperationException(Properties.Resources.customResolversNotSupported);
}

if (propertyMap.CustomMapExpression == null && !propertyMap.SourceMembers.Any())
throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.srcMemberCannotBeNullFormat, typeSource.Name, typeDestination.Name, sourceFullName));
Expand All @@ -746,7 +742,7 @@ TypeMap GetTypeMap() => BothTypesAreAnonymous()
var childFullName = sourceFullName.Substring(sourceFullName.IndexOf(period, StringComparison.OrdinalIgnoreCase) + 1);

FindDestinationFullName(sourceMemberInfo.GetMemberType(), propertyMap.CustomMapExpression == null
? propertyMap.SourceMember.GetMemberType()
? propertyMap.SourceMembers.Last().GetMemberType()
: propertyMap.CustomMapExpression.ReturnType, childFullName, propertyMapInfoList);
}
}
Expand Down

0 comments on commit 5309cfa

Please sign in to comment.