@@ -62,6 +62,161 @@ public void Can_convert_return_type()
6262 output1 . First ( ) . Year . ShouldBe ( 2000 ) ;
6363 output2 . Year . ShouldBe ( 2000 ) ;
6464 }
65+
66+ [ Fact ]
67+ public void Replace_operator_when_operands_change ( )
68+ {
69+ var config = new MapperConfiguration ( cfg => {
70+ cfg . AddExpressionMapping ( ) ;
71+ cfg . CreateMap < Source , Dest > ( ) . ReverseMap ( ) ;
72+ } ) ;
73+
74+ var mapper = config . CreateMapper ( ) ;
75+
76+ Expression < Func < Source , bool > > expression = x => x == default ( Source ) ;
77+
78+ var mapped = mapper . MapExpression < Expression < Func < Dest , bool > > > ( expression ) ;
79+ }
80+ }
81+
82+ public struct Source
83+ {
84+ public Source ( int i ) { val = i ; }
85+ public int val ;
86+
87+ public static implicit operator int ( Source i )
88+ {
89+ return i . val ;
90+ }
91+
92+ public static implicit operator Source ( int i )
93+ {
94+ return new Source ( i ) ;
95+ }
96+
97+ public static bool operator < ( Source a , Source b )
98+ {
99+ return a . val < b . val ;
100+ }
101+
102+ public static bool operator > ( Source a , Source b )
103+ {
104+ return a . val > b . val ;
105+ }
106+
107+ public static bool operator == ( Source a , Source b )
108+ {
109+ return a . val == b . val ;
110+ }
111+
112+ public static bool operator == ( Source a , int b )
113+ {
114+ return a . val == b ;
115+ }
116+
117+ public static bool operator == ( int a , Source b )
118+ {
119+ return a == b . val ;
120+ }
121+
122+ public static bool operator != ( Source a , Source b )
123+ {
124+ return a . val != b . val ;
125+ }
126+
127+ public static bool operator != ( Source a , int b )
128+ {
129+ return a . val != b ;
130+ }
131+
132+ public static bool operator != ( int a , Source b )
133+ {
134+ return a != b . val ;
135+ }
136+
137+ public override int GetHashCode ( )
138+ {
139+ return this . val . GetHashCode ( ) ;
140+ }
141+
142+ public override bool Equals ( object obj )
143+ {
144+ if ( obj is Source )
145+ return this == ( Source ) obj ;
146+ if ( obj is int )
147+ return this == ( Source ) ( ( int ) obj ) ;
148+ return false ;
149+ }
150+ }
151+
152+ public struct Dest
153+ {
154+ public Dest ( int i ) { val = i ; }
155+ public int val ;
156+
157+ public static implicit operator int ( Dest i )
158+ {
159+ return i . val ;
160+ }
161+
162+ public static implicit operator Dest ( int i )
163+ {
164+ return new Dest ( i ) ;
165+ }
166+
167+ public static bool operator < ( Dest a , Dest b )
168+ {
169+ return a . val < b . val ;
170+ }
171+
172+ public static bool operator > ( Dest a , Dest b )
173+ {
174+ return a . val > b . val ;
175+ }
176+
177+ public static bool operator == ( Dest a , Dest b )
178+ {
179+ return a . val == b . val ;
180+ }
181+
182+ public static bool operator == ( Dest a , int b )
183+ {
184+ return a . val == b ;
185+ }
186+
187+ public static bool operator == ( int a , Dest b )
188+ {
189+ return a == b . val ;
190+ }
191+
192+ public static bool operator != ( Dest a , Dest b )
193+ {
194+ return a . val != b . val ;
195+ }
196+
197+ public static bool operator != ( Dest a , int b )
198+ {
199+ return a . val != b ;
200+ }
201+
202+ public static bool operator != ( int a , Dest b )
203+ {
204+ return a != b . val ;
205+ }
206+
207+ public override int GetHashCode ( )
208+ {
209+ return this . val . GetHashCode ( ) ;
210+ }
211+
212+ public override bool Equals ( object obj )
213+ {
214+ if ( obj is Dest )
215+ return this == ( Dest ) obj ;
216+ if ( obj is int )
217+ return this == ( Dest ) ( ( int ) obj ) ;
218+ return false ;
219+ }
65220 }
66221
67222 public struct Garage
0 commit comments