@@ -82,6 +82,9 @@ public static implicit operator string(Foo other)
8282
8383 }
8484
85+ public class InheritedFoo : Foo
86+ { }
87+
8588 public class Bar
8689 {
8790 public string OtherValue { get ; set ; }
@@ -97,6 +100,17 @@ public void Should_use_the_implicit_conversion_operator()
97100
98101 _bar . OtherValue . ShouldBe ( "Hello" ) ;
99102 }
103+
104+ [ Fact ]
105+ public void Should_use_the_inherited_implicit_conversion_operator ( )
106+ {
107+ var source = new InheritedFoo { Value = "Hello" } ;
108+
109+ var config = new MapperConfiguration ( cfg => { } ) ;
110+ _bar = config . CreateMapper ( ) . Map < InheritedFoo , Bar > ( source ) ;
111+
112+ _bar . OtherValue . ShouldBe ( "Hello" ) ;
113+ }
100114 }
101115
102116 public class When_mapping_to_classes_with_explicit_conversion_operator_on_the_destination
@@ -147,6 +161,9 @@ public static explicit operator Bar(Foo other)
147161 }
148162 }
149163
164+ public class InheritedFoo : Foo
165+ { }
166+
150167 public class Bar
151168 {
152169 public string OtherValue { get ; set ; }
@@ -159,5 +176,16 @@ public void Should_use_the_explicit_conversion_operator()
159176 _bar = config . CreateMapper ( ) . Map < Foo , Bar > ( new Foo { Value = "Hello" } ) ;
160177 _bar . OtherValue . ShouldBe ( "Hello" ) ;
161178 }
179+
180+ [ Fact ]
181+ public void Should_use_the_inherited_explicit_conversion_operator ( )
182+ {
183+ var source = new InheritedFoo { Value = "Hello" } ;
184+
185+ var config = new MapperConfiguration ( cfg => { } ) ;
186+ _bar = config . CreateMapper ( ) . Map < InheritedFoo , Bar > ( source ) ;
187+
188+ _bar . OtherValue . ShouldBe ( "Hello" ) ;
189+ }
162190 }
163- }
191+ }
0 commit comments