return 42;
}
+ public int invoke_pass_nullable (int? i) {
+ return (int)i;
+ }
+
public int? invoke_return_nullable_null () {
return null;
}
+ public int invoke_pass_nullable_null (int? i) {
+ return i.HasValue ? 1 : 2;
+ }
+
public void invoke_type_load () {
new Class3 ();
}
m = s.Type.GetMethod ("ToString");
v = s.InvokeMethod (e.Thread, m, null);
+ // pass nullable as argument
+ m = t.GetMethod ("invoke_pass_nullable");
+ v = this_obj.InvokeMethod (e.Thread, m, new Value [] { s });
+ AssertValue (42, v);
+
// return nullable null
m = t.GetMethod ("invoke_return_nullable_null");
v = this_obj.InvokeMethod (e.Thread, m, null);
m = s.Type.GetMethod ("ToString");
v = s.InvokeMethod (e.Thread, m, null);
+ // pass nullable null as argument
+ m = t.GetMethod ("invoke_pass_nullable_null");
+ v = this_obj.InvokeMethod (e.Thread, m, new Value [] { s });
+ AssertValue (2, v);
+
+ return;
+
// pass primitive
m = t.GetMethod ("invoke_pass_primitive");
Value[] args = new Value [] {
args [i] = arg_buf [i];
}
} else {
- arg_buf [i] = (guint8 *)g_alloca (mono_class_instance_size (mono_class_from_mono_type (sig->params [i])));
+ MonoClass *arg_class = mono_class_from_mono_type (sig->params [i]);
+ arg_buf [i] = (guint8 *)g_alloca (mono_class_instance_size (arg_class));
err = decode_value (sig->params [i], domain, arg_buf [i], p, &p, end);
if (err != ERR_NONE)
break;
- args [i] = arg_buf [i];
+ if (mono_class_is_nullable (arg_class)) {
+ args [i] = mono_nullable_box (arg_buf [i], arg_class, &error);
+ mono_error_assert_ok (&error);
+ } else {
+ args [i] = arg_buf [i];
+ }
}
}