@@ -303,29 +303,14 @@ private Expression AddPropertyNode(MemberExpression node)
303303 }
304304 }
305305
306- private static Func < object , object > ? CreateGetter ( PropertyInfo info )
306+ private static Func < object , object ? > ? CreateGetter ( PropertyInfo info )
307307 {
308- if ( info . GetMethod == null )
309- return null ;
310- var target = Expression . Parameter ( typeof ( object ) , "target" ) ;
311- return Expression . Lambda < Func < object , object > > (
312- Expression . Convert ( Expression . Call ( Expression . Convert ( target , info . DeclaringType ! ) , info . GetMethod ) ,
313- typeof ( object ) ) ,
314- target )
315- . Compile ( ) ;
308+ return info . CanRead ? info . GetValue : null ;
316309 }
317310
318311 private static Action < object , object ? > ? CreateSetter ( PropertyInfo info )
319312 {
320- if ( info . SetMethod == null )
321- return null ;
322- var target = Expression . Parameter ( typeof ( object ) , "target" ) ;
323- var value = Expression . Parameter ( typeof ( object ) , "value" ) ;
324- return Expression . Lambda < Action < object , object ? > > (
325- Expression . Call ( Expression . Convert ( target , info . DeclaringType ! ) , info . SetMethod ,
326- Expression . Convert ( value , info . SetMethod . GetParameters ( ) [ 0 ] . ParameterType ) ) ,
327- target , value )
328- . Compile ( ) ;
313+ return info . CanWrite ? info . SetValue : null ;
329314 }
330315
331316 private static T GetValue < T > ( Expression expr )
0 commit comments