File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed
Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,10 @@ private void AddValueTransformers(TypeMap typeMap)
104104 }
105105 private void ConfigureReverseMap ( TypeMap typeMap )
106106 {
107- ReverseSourceMembers ( typeMap ) ;
107+ if ( ! typeMap . Types . ContainsGenericParameters )
108+ {
109+ ReverseSourceMembers ( typeMap ) ;
110+ }
108111 foreach ( var destProperty in typeMap . PropertyMaps . Where ( pm => pm . Ignored ) )
109112 {
110113 ReverseMapExpression . ForSourceMemberCore ( destProperty . DestinationName , opt => opt . DoNotValidate ( ) ) ;
Original file line number Diff line number Diff line change 11namespace AutoMapper . UnitTests ;
2+ public class ForPathGenericsSource : AutoMapperSpecBase
3+ {
4+ class Source < T >
5+ {
6+ public InnerSource Inner ;
7+ }
8+ class InnerSource
9+ {
10+ public int Id ;
11+ }
12+ class Destination
13+ {
14+ public int InnerId ;
15+ }
16+ protected override MapperConfiguration CreateConfiguration ( ) => new ( c => c . CreateMap ( typeof ( Source < > ) , typeof ( Destination ) ) . ReverseMap ( ) ) ;
17+ [ Fact ]
18+ public void Should_work ( ) => Map < Destination > ( new Source < int > { Inner = new ( ) { Id = 42 } } ) . InnerId . ShouldBe ( 42 ) ;
19+ }
20+ public class ForPathGenerics : AutoMapperSpecBase
21+ {
22+ class Source < T >
23+ {
24+ public InnerSource Inner ;
25+ }
26+ class InnerSource
27+ {
28+ public int Id ;
29+ }
30+ class Destination < T >
31+ {
32+ public int InnerId ;
33+ }
34+ protected override MapperConfiguration CreateConfiguration ( ) => new ( c => c . CreateMap ( typeof ( Source < > ) , typeof ( Destination < > ) ) . ReverseMap ( ) ) ;
35+ [ Fact ]
36+ public void Should_work ( ) => Map < Destination < int > > ( new Source < int > { Inner = new ( ) { Id = 42 } } ) . InnerId . ShouldBe ( 42 ) ;
37+ }
238public class ReadonlyPropertiesGenerics : AutoMapperSpecBase
339{
440 class Source
You can’t perform that action at this time.
0 commit comments