[Mono-bugs] [Bug 65988][Blo] New - ModuleBuilder.DefineType creates a type even if the type name is not unique
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Wed, 15 Sep 2004 08:24:11 -0400 (EDT)
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by martin.tapp@cae.com.
http://bugzilla.ximian.com/show_bug.cgi?id=65988
--- shadow/65988 2004-09-15 08:24:11.000000000 -0400
+++ shadow/65988.tmp.12706 2004-09-15 08:24:11.000000000 -0400
@@ -0,0 +1,66 @@
+Bug#: 65988
+Product: Mono: Class Libraries
+Version: unspecified
+OS: Red Hat 9.0
+OS Details:
+Status: NEW
+Resolution:
+Severity: 040 One week
+Priority: Blocker
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: martin.tapp@cae.com
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: ModuleBuilder.DefineType creates a type even if the type name is not unique
+
+Description of Problem:
+On Mono, ModuleBuilder.DefineType defines a type even if the type name is
+not unique and the exception ArgumentException has been thrown, but on
+MS.NET, the type is not defined when the exception has been thrown.
+
+Steps to reproduce the problem:
+ public static TypeBuilder DefineType(ModuleBuilder iModuleBuilder,Type
+iParent,string iTypeName)
+ {
+ string wTypeName = iTypeName;
+ TypeBuilder wTypeBuilder = null;
+ uint i = 1;
+ // Make sure the type name is unique
+ while(wTypeBuilder == null)
+ {
+ try
+ {
+ wTypeBuilder = iModuleBuilder.DefineType(wTypeName,
+(TypeAttributes)TypeAttributes.Public|TypeAttributes.Class,iParent);
+ }
+ catch(ArgumentException)
+ {
+ // Type name not unique, construct a unique name for it
+ wTypeName = string.Concat(iTypeName,"__",i++.ToString());
+ }
+ }
+
+ return wTypeBuilder;
+ }
+
+ // In code, call DefineType method
+ DefineType(wMyModuleBuilder,"A.MyClass",typeof(Object)); // -> A.MyClass
+ DefineType(wMyModuleBuilder,"A.MyClass",typeof(Object)); // ->
+A.MyClass__1
+
+Actual Results:
+In generated assembly, the types found are:
+- A.MyClass
+- A.MyClass
+- A.MyClass__1
+
+Expected Results:
+In generated assembly, the types found should have been:
+- A.MyClass
+- A.MyClass__1
+
+How often does this happen?
+Always