Skip to content

Commit 9408f3e

Browse files
authored
Merge branch 'master' into feature/upgrade-automapper8
2 parents 9207bb7 + fb2f400 commit 9408f3e

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/AutoMapper.Extensions.ExpressionMapping.UnitTests/XpressionMapperTests.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,19 @@ void CallSomeAction<T>(T val)
635635
{
636636
this.val = val;
637637
}
638+
639+
[Fact]
640+
public void Can_map_expression_when_mapped_properties_have_a_different_generic_argument_counts()
641+
{
642+
//Arrange
643+
Expression<Func<ListParent, bool>> src = x => x.List.Count == 0;
644+
645+
//Act
646+
Expression<Func<ListParentExtension, bool>> dest = mapper.Map<Expression<Func<ListParentExtension, bool>>>(src);
647+
648+
//Assert
649+
Assert.NotNull(dest);
650+
}
638651
#endregion Tests
639652

640653
private static void SetupAutoMapper()
@@ -1018,6 +1031,20 @@ class ItemEntity
10181031
public string Name { get; set; }
10191032
}
10201033

1034+
class ListParentExtension
1035+
{
1036+
public ListExtension List { get; set; }
1037+
}
1038+
1039+
class ListParent : List<string>
1040+
{
1041+
public List<string> List { get; set; }
1042+
}
1043+
1044+
class ListExtension : List<string>
1045+
{
1046+
}
1047+
10211048
public class OrganizationProfile : Profile
10221049
{
10231050
public OrganizationProfile()
@@ -1112,6 +1139,13 @@ public OrganizationProfile()
11121139

11131140
CreateMap<OptionT, OptionS>();
11141141

1142+
CreateMap<ListParentExtension, ListParent>()
1143+
.ReverseMap();
1144+
CreateMap<ListExtension, List<string>>()
1145+
.ForMember(d => d.Count, opt => opt.MapFrom(s => s.Count))
1146+
.ReverseMap()
1147+
.ForMember(d => d.Count, opt => opt.MapFrom(s => s.Count));
1148+
11151149
CreateMissingTypeMaps = true;
11161150
}
11171151
}

0 commit comments

Comments
 (0)