[Mono-bugs] [Bug 565127] New: GetGenericParameterConstraints fails on methods in dynamic modules
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Dec 16 07:37:03 EST 2009
http://bugzilla.novell.com/show_bug.cgi?id=565127
http://bugzilla.novell.com/show_bug.cgi?id=565127#c0
Summary: GetGenericParameterConstraints fails on methods in
dynamic modules
Classification: Mono
Product: Mono: Runtime
Version: 2.6.x
Platform: x86
OS/Version: Windows 7
Status: NEW
Severity: Normal
Priority: P5 - None
Component: generics
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: tomas.matousek at microsoft.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
Created an attachment (id=332911)
--> (http://bugzilla.novell.com/attachment.cgi?id=332911)
Compiled code
User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1;
Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729;
Media Center PC 6.0; InfoPath.3; MS-RTC LM 8; MALC)
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace ConsoleApplication1 {
class Program {
static void Main(string[] args) {
var ab = AppDomain.CurrentDomain.DefineDynamicAssembly(new
AssemblyName("foo"), AssemblyBuilderAccess.Run);
var modb = ab.DefineDynamicModule("foo");
var tb = modb.DefineType("C", TypeAttributes.Class |
TypeAttributes.Public);
var mb = tb.DefineMethod("m", MethodAttributes.Public |
MethodAttributes.Static);
var gps = mb.DefineGenericParameters("T");
mb.SetParameters(gps);
mb.SetReturnType(typeof(void));
var il = mb.GetILGenerator();
il.Emit(OpCodes.Ret);
var ti = tb.CreateType();
var mi = ti.GetMethod("m");
var mii = mi.MakeGenericMethod(typeof(int));
foreach (var t in mii.GetGenericMethodDefinition().GetParameters())
{
Console.WriteLine(t);
foreach (var c in
t.ParameterType.GetGenericParameterConstraints()) {
Console.WriteLine(c);
}
}
}
}
}
Reproducible: Always
Steps to Reproduce:
1. compile and run the code above or run the attached .exe
Actual Results:
Crash:
Unhandled Exception: System.InvalidOperationException: Operation is not valid
due to the current state of the object
at
System.Reflection.Emit.GenericTypeParameterBuilder.GetGenericParameterConstraints
() [0x00000] in <filename unknown
>:0
at ConsoleApplication1.Program.Main (System.String[] args) [0x00000] in
<filename unknown>:0
Expected Results:
T
--
Configure bugmail: http://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