[Mono-bugs] [Bug 416632] New: TypeBuilder shouldn' t add default constructor if a constructor was already defined using DefineMethod ()
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Tue Aug 12 11:36:25 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=416632
Summary: TypeBuilder shouldn't add default constructor if a
constructor was already defined using DefineMethod()
Product: Mono: Class Libraries
Version: 2.0
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: CORLIB
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: jeroen at sumatra.nl
QAContact: mono-bugs at lists.ximian.com
Found By: ---
The following program results in an assembly with a type that has two default
constructors:
using System;
using System.Reflection;
using System.Reflection.Emit;
class Program
{
static void Main(string[] args)
{
AssemblyBuilder ab =
AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("Foo"),
AssemblyBuilderAccess.RunAndSave);
ModuleBuilder modb = ab.DefineDynamicModule("Foo.exe");
TypeBuilder tb = modb.DefineType("MyType",
TypeAttributes.Public | TypeAttributes.Class);
MethodBuilder mb = tb.DefineMethod(".ctor",
MethodAttributes.Public | MethodAttributes.RTSpecialName |
MethodAttributes.SpecialName);
ILGenerator ilgen = mb.GetILGenerator();
ilgen.Emit(OpCodes.Ldarg_0);
ilgen.Emit(OpCodes.Call,
typeof(object).GetConstructor(Type.EmptyTypes));
ilgen.Emit(OpCodes.Ret);
tb.CreateType();
ab.Save("Foo.exe");
}
}
On Microsoft .NET 2.0 this works correctly.
--
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