AssertValue (Int32.MaxValue - 5, (f as StructMirror).Fields [0]);
// enums
-
FieldInfoMirror field = o.Type.GetField ("field_enum");
f = o.GetValue (field);
(f as EnumMirror).Value = 5;
f = o.GetValue (field);
o.SetValue (field, f);
+ // nullables
+ field = o.Type.GetField ("field_nullable");
+ f = o.GetValue (field);
+ AssertValue (0, (f as StructMirror).Fields [0]);
+ AssertValue (false, (f as StructMirror).Fields [1]);
+ o.SetValue (field, vm.CreateValue (6));
+ f = o.GetValue (field);
+ AssertValue (6, (f as StructMirror).Fields [0]);
+ AssertValue (true, (f as StructMirror).Fields [1]);
+ o.SetValue (field, vm.CreateValue (null));
+ f = o.GetValue (field);
+ AssertValue (0, (f as StructMirror).Fields [0]);
+ AssertValue (false, (f as StructMirror).Fields [1]);
+
// Argument checking
AssertThrows<ArgumentNullException> (delegate () {
o.SetValues (null, new Value [0]);
}
static ErrorCode
-decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit)
+decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit);
+
+static ErrorCode
+decode_value_internal (MonoType *t, int type, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit)
{
int err;
- int type = decode_byte (buf, &buf, limit);
if (type != t->type && !MONO_TYPE_IS_REFERENCE (t) &&
!(t->type == MONO_TYPE_I && type == MONO_TYPE_VALUETYPE) &&
return 0;
}
+static ErrorCode
+decode_value (MonoType *t, MonoDomain *domain, guint8 *addr, guint8 *buf, guint8 **endbuf, guint8 *limit)
+{
+ int err;
+ int type = decode_byte (buf, &buf, limit);
+
+ if (t->type == MONO_TYPE_GENERICINST && mono_class_is_nullable (mono_class_from_mono_type (t))) {
+ MonoType *targ = t->data.generic_class->context.class_inst->type_argv [0];
+ guint8 *nullable_buf;
+
+ if (targ->type == type) {
+ nullable_buf = g_malloc (mono_class_instance_size (mono_class_from_mono_type (targ)));
+ err = decode_value_internal (targ, type, domain, nullable_buf, buf, endbuf, limit);
+ if (err) {
+ g_free (nullable_buf);
+ return err;
+ }
+ mono_nullable_init (addr, mono_value_box (domain, mono_class_from_mono_type (targ), nullable_buf), mono_class_from_mono_type (t));
+ g_free (nullable_buf);
+ *endbuf = buf;
+ return ERR_NONE;
+ } else if (type == VALUE_TYPE_ID_NULL) {
+ mono_nullable_init (addr, NULL, mono_class_from_mono_type (t));
+ *endbuf = buf;
+ return ERR_NONE;
+ }
+ }
+
+ return decode_value_internal (t, type, domain, addr, buf, endbuf, limit);
+}
+
static void
add_var (Buffer *buf, MonoType *t, MonoDebugVarInfo *var, MonoContext *ctx, MonoDomain *domain, gboolean as_vtype)
{