Skip to content

Supporting AutoMapper v12. #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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