File tree Expand file tree Collapse file tree 5 files changed +35
-0
lines changed
AgileMapper/Configuration Expand file tree Collapse file tree 5 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 8181 <Compile Include =" Dictionaries\Configuration\WhenConfiguringNestedDictionaryMapping.cs" />
8282 <Compile Include =" Dictionaries\Configuration\WhenConfiguringTargetDictionaryMapping.cs" />
8383 <Compile Include =" Dictionaries\WhenCreatingRootDictionaryMembers.cs" />
84+ <Compile Include =" TestClasses\IPublicInterface.cs" />
8485 <Compile Include =" TestClasses\MegaProduct.cs" />
8586 <Compile Include =" TestClasses\ProductDto.cs" />
8687 <Compile Include =" TestClasses\ProductDtoMega.cs" />
115116 <Compile Include =" TestClasses\PaymentTypeUk.cs" />
116117 <Compile Include =" TestClasses\PaymentTypeUs.cs" />
117118 <Compile Include =" TestClasses\PublicFactoryMethod.cs" />
119+ <Compile Include =" TestClasses\PublicImplementation.cs" />
118120 <Compile Include =" TestClasses\PublicSealed.cs" />
119121 <Compile Include =" TestClasses\PublicTwoFields.cs" />
120122 <Compile Include =" TestClasses\PublicTwoParamCtor.cs" />
Original file line number Diff line number Diff line change 1+ namespace AgileObjects . AgileMapper . UnitTests . TestClasses
2+ {
3+ public interface IPublicInterface < T >
4+ {
5+ T Value { get ; set ; }
6+ }
7+ }
Original file line number Diff line number Diff line change 1+ namespace AgileObjects . AgileMapper . UnitTests . TestClasses
2+ {
3+ public class PublicImplementation < T > : IPublicInterface < T >
4+ {
5+ public T Value { get ; set ; }
6+ }
7+ }
Original file line number Diff line number Diff line change @@ -71,5 +71,19 @@ public void ShouldMapFromASimpleTypeToObject()
7171
7272 result . Value . ShouldBe ( "Oi 'Arold!" ) ;
7373 }
74+
75+ // See https://github.com/agileobjects/AgileMapper/issues/11
76+ [ Fact ]
77+ public void ShouldMapFromAnInterface ( )
78+ {
79+ IPublicInterface < string > source = new PublicImplementation < string >
80+ {
81+ Value = "Interfaces!"
82+ } ;
83+
84+ var result = Mapper . Map ( source ) . ToANew < PublicField < string > > ( ) ;
85+
86+ result . Value . ShouldBe ( "Interfaces!" ) ;
87+ }
7488 }
7589}
Original file line number Diff line number Diff line change @@ -239,6 +239,11 @@ private static bool SkipDerivedTypePairsLookup(
239239
240240 private static Type GetRootType ( Type type )
241241 {
242+ if ( type . IsInterface )
243+ {
244+ return type ;
245+ }
246+
242247 var parentType = type ;
243248
244249 while ( parentType != typeof ( object ) )
You can’t perform that action at this time.
0 commit comments