internal override Expression GetBoundValue(ActionBinder binder, Type type, Expression instance) { if (DeclaringType.IsGenericType && DeclaringType.GetGenericTypeDefinition() == typeof(StrongBox <>)) { // work around a CLR bug where we can't access generic fields from dynamic methods. return(Ast.Call( typeof(BinderOps).GetMethod("GetBox").MakeGenericMethod(DeclaringType.GetGenericArguments()), Ast.ConvertHelper(instance, DeclaringType) )); } if (IsPublic && DeclaringType.IsPublic) { return(Ast.ReadField( Ast.Convert(instance, Field.DeclaringType), Field )); } return(Ast.Call( Ast.ConvertHelper(Ast.RuntimeConstant(Field), typeof(FieldInfo)), typeof(FieldInfo).GetMethod("GetValue"), Ast.ConvertHelper(instance, typeof(object)) )); }