[Mono-bugs] [Bug 73142][Nor] New - Missing System.ArgumentException in SetCustomAttribute

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Tue, 1 Mar 2005 03:48:46 -0500 (EST)


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 marek.safar@seznam.cz.

http://bugzilla.ximian.com/show_bug.cgi?id=73142

--- shadow/73142	2005-03-01 03:48:46.000000000 -0500
+++ shadow/73142.tmp.4069	2005-03-01 03:48:46.000000000 -0500
@@ -0,0 +1,89 @@
+Bug#: 73142
+Product: Mono: Class Libraries
+Version: 1.1
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: marek.safar@seznam.cz               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Missing System.ArgumentException in SetCustomAttribute
+
+Steps to reproduce the problem:
+1. compile this
+
+
+using System;
+using System.Reflection;
+using System.Reflection.Emit;
+using System.Runtime.InteropServices;
+using System.Threading;
+
+public class Foo {
+
+	public static void Main () {
+		Type [] ctorParams = new Type[] {typeof(string) };
+			
+		ConstructorInfo classCtorInfo = 
+			typeof (GuidAttribute).GetConstructor (BindingFlags.Instance |
+			BindingFlags.Public, null, ctorParams, null);
+
+		CustomAttributeBuilder typeCABuilder = new CustomAttributeBuilder (
+			classCtorInfo,
+			new object [] { "aaaaaaa" } );
+
+
+
+		// preconditions
+		AppDomain currentDomain = Thread.GetDomain();
+	
+		AssemblyName myAsmName = new AssemblyName();
+		myAsmName.Name = "MyAssembly";
+
+		AssemblyBuilder myAsmBuilder = currentDomain.DefineDynamicAssembly(
+			myAsmName, AssemblyBuilderAccess.Run);
+
+		ModuleBuilder myModBuilder = myAsmBuilder.DefineDynamicModule("MyModule");
+
+		TypeBuilder myTypeBuilder = myModBuilder.DefineType("MyType",
+			TypeAttributes.Public);
+		//
+	
+		myTypeBuilder.SetCustomAttribute(typeCABuilder);
+
+		myTypeBuilder.CreateType();
+
+	}	    
+	    
+}
+
+2. run produced exe
+
+Actual Results:
+
+No exception, no error
+
+
+Expected Results:
+
+MS throws
+
+Unhandled Exception: System.ArgumentException: Invalid custom attribute
+provided: 'Incorrect UUID format.'
+   at
+System.Reflection.Emit.TypeBuilder.InternalCreateCustomAttribute(Int32
+tkAssociate, Int32 tkConstructor, Byte[] attr, Module module, Boolean toDisk)
+   at
+System.Reflection.Emit.CustomAttributeBuilder.CreateCustomAttribute(Module
+Builder mod, Int32 tkOwner)
+   at
+System.Reflection.Emit.TypeBuilder.SetCustomAttribute(CustomAttributeBuild
+er customBuilder)
+   at Foo.Main()