[Mono-bugs] [Bug 607106] New: SRE: DefineMethodOverride does not work with defined method
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed May 19 08:31:02 EDT 2010
http://bugzilla.novell.com/show_bug.cgi?id=607106
http://bugzilla.novell.com/show_bug.cgi?id=607106#c0
Summary: SRE: DefineMethodOverride does not work with defined
method
Classification: Mono
Product: Mono: Class Libraries
Version: unspecified
Platform: Other
OS/Version: Other
Status: NEW
Severity: Major
Priority: P5 - None
Component: CORLIB
AssignedTo: rkumpera at novell.com
ReportedBy: msafar at novell.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
Compile & Run
using System;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
class C
{
public static void Main ()
{
TypeBuilder tb;
ILGenerator il_gen;
AssemblyName assemblyName = new AssemblyName ();
assemblyName.Name = "MonoTests.System.Reflection.Emit.ILGeneratorTest";
AssemblyBuilder assembly = Thread.GetDomain ().DefineDynamicAssembly (
assemblyName, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder module = assembly.DefineDynamicModule ("temp.dll");
TypeBuilder tInterface = module.DefineType("I",
TypeAttributes.Interface | TypeAttributes.Abstract);
MethodBuilder i_mb = tInterface.DefineMethod("M",
MethodAttributes.Public | MethodAttributes.HideBySig |
MethodAttributes.NewSlot | MethodAttributes.Virtual |
MethodAttributes.Abstract,
null,
Type.EmptyTypes);
GenericTypeParameterBuilder[] i_typeParameters =
i_mb.DefineGenericParameters("T");
tInterface.CreateType ();
tb = module.DefineType ("T", TypeAttributes.Public);
tb.AddInterfaceImplementation(tInterface);
MethodBuilder mb = tb.DefineMethod("I.M",
MethodAttributes.Public | MethodAttributes.HideBySig |
MethodAttributes.NewSlot | MethodAttributes.Virtual |
MethodAttributes.Final,
null,
Type.EmptyTypes);
GenericTypeParameterBuilder[] typeParameters =
mb.DefineGenericParameters("TT");
tb.DefineMethodOverride(mb, i_mb);
il_gen = mb.GetILGenerator ();
il_gen.Emit (OpCodes.Ret);
tb.CreateType ();
assembly.Save("temp.dll");
}
}
Produced temp.dll is invalid because of wrong Method Declaration Token
MethodImpl #1 (00000001)
-------------------------------------------------------
Method Body Token : 0x06000003
Method Declaration Token : 0x0a000002
NET verifier and runtime complains with
[MD]: Error: Class implements interface but not method (class:0x02000003;
interf
ace:0x02000002; method:0x06000001). [token:0x09000001]
Same error is not detected by Mono verifier
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list