[Mono-bugs] [Bug 350286] New: Importing generic instance methods with SRE emitted types on MS fails
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Dec 21 09:11:52 EST 2007
https://bugzilla.novell.com/show_bug.cgi?id=350286
Summary: Importing generic instance methods with SRE emitted
types on MS fails
Product: Mono: Class Libraries
Version: SVN
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Cecil
AssignedTo: jbevain at novell.com
ReportedBy: rkvinge at novell.com
QAContact: mono-bugs at ximian.com
Found By: ---
Repro:
using System.Collections.Generic;
using System;
using System.Reflection;
using System.Reflection.Emit;
using Mono.Cecil;
class test
{
static void Main ()
{
AssemblyName name = new AssemblyName ();
name.Name = "tester";
AssemblyBuilder ab =
System.AppDomain.CurrentDomain.DefineDynamicAssembly(name,
System.Reflection.Emit.AssemblyBuilderAccess.Save, ".");
ModuleBuilder mb = ab.DefineDynamicModule("tester",
"tesster.dll", false);
TypeBuilder tb = mb.DefineType ("T");
Type t = typeof (List<>).MakeGenericType (tb);
MethodInfo m = TypeBuilder.GetMethod(t, typeof
(List<>).GetMethod ("AddRange")); // Typet.GetMethod ("AddRange");
Console.WriteLine (m.GetType ().FullName);
AssemblyDefinition a = AssemblyFactory.DefineAssembly("tester",
AssemblyKind.Dll);
MethodReference mr = a.MainModule.Import (m);
Console.WriteLine (mr.Name);
}
}
Result on MS:
Z:\>test.exe
System.Reflection.Emit.MethodOnTypeBuilderInstantiation
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has
been thrown by the target of an invocation. --->
System.InvalidOperationException: Operation is not valid due to the current
state of the object.
at System.Reflection.MemberInfo.get_MetadataToken()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[]
arguments, SignatureStruct& sig, MethodAttributes methodAttributes,
RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[]
arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle
typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean
skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[]
index)
at Mono.Cecil.ReflectionHelper.GetMetadataToken(MethodInfo mi)
at Mono.Cecil.ReflectionHelper.ImportMethodBase(MethodBase mb, Type retType,
ImportContext context)
at Mono.Cecil.ModuleDefinition.Import(MethodBase meth)
at test.Main()
Result on Mono:
rolf at linux:~/test> mono test.exe
System.Reflection.MonoGenericMethod
AddRange
--
Configure bugmail: https://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