[Mono-bugs] [Bug 354047] Type created by MakeGenericType () from a finished TypeBuilder is flagged as a generic type definition

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu May 8 15:39:19 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=354047

User rkumpera at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=354047#c6


Rodrigo Kumpera <rkumpera at novell.com> changed:

           What    |Removed                                         |Added
----------------------------------------------------------------------------
             Status|NEW                                             |ASSIGNED




--- Comment #6 from Rodrigo Kumpera <rkumpera at novell.com>  2008-05-08 13:39:19 MST ---
The issue here is that the generic params on the created type are owned by the
TypeBuilder. This is another issue with our implementation. Take the following
program:


using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;

public class Tests
{
        public static void Main (String[] args) {
                AssemblyName assemblyName = new AssemblyName ();
                assemblyName.Name = "foo";

                AssemblyBuilder assembly =
                        Thread.GetDomain ().DefineDynamicAssembly (
                                        assemblyName,
AssemblyBuilderAccess.RunAndSave);

                ModuleBuilder module = assembly.DefineDynamicModule ("foo");

                TypeBuilder tb = module.DefineType ("Foo",
TypeAttributes.Public);
                GenericTypeParameterBuilder[] typeParams =
tb.DefineGenericParameters (new String[] { "T" });

                Type t = tb.CreateType ();

                Type inst = tb.MakeGenericType (typeParams [0]);

                Console.WriteLine ("inst is gtd {0}",
inst.IsGenericTypeDefinition);
                Console.WriteLine ("tb == created type {0} ", tb == t);
                Console.WriteLine ("tb arg == created type arg
{0}",tb.GetGenericArguments()[0] == t.GetGenericArguments()[0]);

                                Console.WriteLine ("tb owns params {0}",
tb.GetGenericArguments()[0].DeclaringType == tb);
                                Console.WriteLine ("res owns params {0}",
t.GetGenericArguments()[0].DeclaringType == t);

        }
}



On MS it prints:
inst is gtd False
tb == created type False
tb arg == created type arg False
tb owns params True
res owns params True

On mono HEAD it prints:
inst is gtd True
tb == created type False 
tb arg == created type arg True
tb owns params True
res owns params False


As you can see the issue is that the generic arguments are shared when they
shouldn't.


-- 
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