Assert.AreEqual (42, res[0]);
}
+
+
+ [Test]
+ public void Ldfld_Regress_9531 () {
+ Build<Example<int>> ();
+ }
+
+ void Build<T> () {
+ var base_class = typeof(T);
+
+ var builder = module.DefineType(genTypeName (),
+ TypeAttributes.Class | TypeAttributes.Sealed | TypeAttributes.Public,
+ base_class);
+
+ var field = builder.BaseType.GetField("Field", BindingFlags.Instance | BindingFlags.Public);
+
+ var cb = builder.DefineConstructor(
+ MethodAttributes.Public | MethodAttributes.SpecialName,
+ CallingConventions.HasThis,
+ new[] { typeof(string) });
+
+ var il = cb.GetILGenerator();
+
+ if (field == null)
+ {
+ throw new InvalidOperationException("wtf");
+ }
+
+ il.Emit(OpCodes.Ldarg_0);
+ il.Emit(OpCodes.Ldarg_1);
+ il.Emit(OpCodes.Stfld, field);
+ il.Emit(OpCodes.Ret);
+
+ builder.CreateType();
+ }
+
+ public class Example<T> {
+ public string Field;
+ }
+
}
}
if (token)
return token;
- if (field->parent->generic_class && field->parent->generic_class->container_class && field->parent->generic_class->container_class->fields) {
- int index = field - field->parent->fields;
- type = field->parent->generic_class->container_class->fields [index].type;
- } else {
- if (is_field_on_inst (field))
- type = get_field_on_inst_generic_type (field);
- else
- type = mono_field_get_type (field);
- }
+ if (is_field_on_inst (field))
+ type = get_field_on_inst_generic_type (field);
+ else
+ type = mono_field_get_type (field);
token = mono_image_get_memberref_token (assembly, &field->parent->byval_arg,
mono_field_get_name (field),
fieldref_encode_signature (assembly, field->parent->image, type));