2004-03-24 Zoltan Varga <vargaz@freemail.hu>
authorZoltan Varga <vargaz@gmail.com>
Wed, 24 Mar 2004 12:16:53 +0000 (12:16 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 24 Mar 2004 12:16:53 +0000 (12:16 -0000)
* CustomAttributeBuilder.cs: Reenable argument checking with MS.NET
compatibility tweaks.

svn path=/trunk/mcs/; revision=24518

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/CustomAttributeBuilder.cs

index ce3df7a634c3086ad322997cd3706c03037ff4f1..eeccecd951bfa667e543aad85773e408b219d440 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-24  Zoltan Varga  <vargaz@freemail.hu>
+
+       * CustomAttributeBuilder.cs: Reenable argument checking with MS.NET
+       compatibility tweaks.
+
 2004-03-23  Martin Baulig  <martin@ximian.com>
 
        * TypeBuilder.cs (TypeBuilder.GetEvents_internal): New internal
index 941ec07f2b59dd553da2828069ee4073c3b1fa27..aebfe4a0b040ae2182b1169cb9ca194b7b9b1def 100755 (executable)
@@ -89,8 +89,6 @@ namespace System.Reflection.Emit {
                        if ((con.Attributes & MethodAttributes.Static) == MethodAttributes.Static ||
                                        (con.Attributes & MethodAttributes.Private) == MethodAttributes.Private)
                                throw new ArgumentException ("Cannot have private or static constructor.");
-                       /* 
-                          FIXME: Enabling this causes regressions
 
                        Type atype = ctor.DeclaringType;
                        int i;
@@ -103,7 +101,12 @@ namespace System.Reflection.Emit {
                                if (fieldValues [i] != null)
                                        // IsEnum does not seem to work on TypeBuilders
                                        if (!(fi.FieldType is TypeBuilder) && !fi.FieldType.IsEnum && !fi.FieldType.IsAssignableFrom (fieldValues [i].GetType ())) {
-                                               throw new ArgumentException ("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
+                                               //
+                                               // mcs allways uses object[] for array types and
+                                               // MS.NET allows this
+                                               //
+                                               if (!fi.FieldType.IsArray)
+                                                       throw new ArgumentException ("Value of field '" + fi.Name + "' does not match field type: " + fi.FieldType);
                                                }
                                i ++;
                        }
@@ -115,11 +118,10 @@ namespace System.Reflection.Emit {
                                Type t = pi.DeclaringType;
                                if ((atype != t) && (!t.IsSubclassOf (atype)) && (!atype.IsSubclassOf (t)))
                                        throw new ArgumentException ("Property '" + pi.Name + "' does not belong to the same class as the constructor");
-                               // FIXME: Check enums and TypeBuilders as well
                                if (propertyValues [i] != null) {
-                                       // IsEnum does not seem to work on TypeBuilders
                                        if (!(pi.PropertyType is TypeBuilder) && !pi.PropertyType.IsEnum && !pi.PropertyType.IsAssignableFrom (propertyValues [i].GetType ()))
-                                               throw new ArgumentException ("Value of property '" + pi.Name + "' does not match property type");
+                                               if (!pi.PropertyType.IsArray)
+                                                       throw new ArgumentException ("Value of property '" + pi.Name + "' does not match property type: " + pi.PropertyType + " -> " + propertyValues [i]);
                                }
                                i ++;
                        }
@@ -129,13 +131,12 @@ namespace System.Reflection.Emit {
                                if (pi != null) {
                                        Type paramType = pi.ParameterType;
                                        if (constructorArgs [i] != null)
-                                               // IsEnum does not seem to work on TypeBuilders
                                                if (!(paramType is TypeBuilder) && !paramType.IsEnum && !paramType.IsAssignableFrom (constructorArgs [i].GetType ()))
-                                                       throw new ArgumentException ("Value of argument " + i + " does not match parameter type: " + paramType);
+                                                       if (!paramType.IsArray)
+                                                               throw new ArgumentException ("Value of argument " + i + " does not match parameter type: " + paramType + " -> " + constructorArgs [i]);
                                }
                                i ++;
                        }
-                       */
                                
                        data = GetBlob (con, constructorArgs, namedProperties, propertyValues, namedFields, fieldValues);
                }