[Mono-bugs] [Bug 399047] New: Broken TypeBuilder.GetField
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Jun 10 15:39:30 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=399047
Summary: Broken TypeBuilder.GetField
Product: Mono: Runtime
Version: SVN
Platform: Other
OS/Version: Other
Status: NEW
Severity: Blocker
Priority: P5 - None
Component: generics
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: msafar at novell.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
1. Compile sample program
2. Run it on mono
3. Disassembly produced file "Instance.exe"
Mono produces invalid generic field reference at IL_0001 in method Test<TA>
IL_0001: ldfld !!0 class G<!!0>::F
should be
// method line 4
.method public
instance default void Test<TA> () cil managed
{
// Method begins at RVA 0x2100
// Code size 8 (0x8)
.maxstack 8
IL_0000: ldnull
IL_0001: ldfld !!0 class G<!!0>::F <-----------
IL_0006: pop
IL_0007: ret
} // end of method P::Test
This blocks my recent changes in gmcs.
using System;
using System.Reflection;
using System.Reflection.Emit;
public class Entry
{
public static int Main ()
{
Instance (1);
return 0;
}
public static void Instance<R> (R r)
{
AssemblyName name = new AssemblyName ("Instance");
AssemblyBuilder asmbuild = System.Threading.Thread.GetDomain
().DefineDynamicAssembly (name, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder mod = asmbuild.DefineDynamicModule
("Instance.exe");
TypeBuilder G = mod.DefineType ("G", TypeAttributes.Public);
Type T = G.DefineGenericParameters ("T") [0];
Type GObj = G.MakeGenericType (new Type [] { T });
FieldBuilder F = G.DefineField ("F", T,
FieldAttributes.Public);
MethodBuilder Foo = G.DefineMethod ("Foo",
MethodAttributes.Public);
{
ILGenerator il = Foo.GetILGenerator ();
il.Emit (OpCodes.Ret);
}
TypeBuilder P = mod.DefineType ("P", TypeAttributes.Public);
MethodBuilder Test = P.DefineMethod ("Test",
MethodAttributes.Public);
Type TATest = Test.DefineGenericParameters ("TA") [0];
{
Type TestGObj = G.MakeGenericType (new Type [] { TATest
});
ILGenerator il = Test.GetILGenerator ();
il.Emit (OpCodes.Ldnull);
il.Emit (OpCodes.Ldfld, TypeBuilder.GetField (TestGObj,
F));
il.Emit (OpCodes.Pop);
il.Emit (OpCodes.Ret);
}
Type rtG = G.CreateType ();
P.CreateType ();
Console.WriteLine ("Instance.exe");
asmbuild.Save ("Instance.exe");
object target = Activator.CreateInstance (rtG.MakeGenericType
(typeof (object)), null);
rtG.MakeGenericType (typeof (object)).InvokeMember ("Foo",
BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null,
target, null);
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list