[Mono-bugs] [Bug 383444] typeof (Type<>) fails when used in custom attribute constructor.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Apr 29 07:52:48 EDT 2008


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

User msafar at novell.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=383444#c2





--- Comment #2 from Marek Safar <msafar at novell.com>  2008-04-29 05:52:48 MST ---
This is SRE bug.

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

namespace ConsoleApplication1
{
        class B<T>
        {
        }

        class Program
        {
                static void Main (string [] args)
                {
                        AssemblyName asmName = new AssemblyName ();
                        asmName.Name = "TestAssembly";

                        AssemblyBuilder asmBuilder = Thread.GetDomain
().DefineDynamicAssembly (
                                asmName, AssemblyBuilderAccess.RunAndSave);

                        ModuleBuilder modBuilder =
asmBuilder.DefineDynamicModule (asmName.Name, asmName.Name + ".dll");

                        TypeBuilder typeBuilder = modBuilder.DefineType
("TestType",
                                TypeAttributes.Public);

                        ConstructorInfo classCtorInfo = typeof
(B<>).GetConstructor (Type.EmptyTypes);

                        CustomAttributeBuilder typeCABuilder = new
CustomAttributeBuilder (
                                classCtorInfo, new object[0]);

                        typeBuilder.SetCustomAttribute (typeCABuilder);

                        Type myType = typeBuilder.CreateType ();

                        asmBuilder.Save (asmName.Name + ".dll");
                }
        }
}


1. Compile
2. Run
3. monodis TestAssembly.dll


Mono runtime emits B`1<!0>::'.ctor'() which is wrong


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