Moved ProviderCollectionTest.cs from System assembly to System.Configuration.
[mono.git] / mcs / class / corlib / System.Reflection / CustomAttributeTypedArgument.cs
index 03f06d3a76c7f5fa7cabadd5c469e39f54504714..41520a144b53c26bd1ad9f0c4499a3fe11f035ba 100644 (file)
@@ -31,6 +31,7 @@
 
 using System;
 using System.Runtime.InteropServices;
+using System.Collections.ObjectModel;
 
 namespace System.Reflection {
 
@@ -44,6 +45,17 @@ namespace System.Reflection {
                {
                        this.argumentType = argumentType;
                        this.value = value;
+
+                       // MS seems to convert arrays into a ReadOnlyCollection
+                       if (value is Array) {
+                               Array a = (Array)value;
+
+                               Type etype = a.GetType ().GetElementType ();
+                               CustomAttributeTypedArgument[] new_value = new CustomAttributeTypedArgument [a.GetLength (0)];
+                               for (int i = 0; i < new_value.Length; ++i)
+                                       new_value [i] = new CustomAttributeTypedArgument (etype, a.GetValue (i));
+                               this.value = new ReadOnlyCollection <CustomAttributeTypedArgument> (new_value);
+                       }
                }
 
                public Type ArgumentType {
@@ -85,14 +97,14 @@ namespace System.Reflection {
                        return (argumentType.GetHashCode () << 16) + (value != null ? value.GetHashCode () : 0);
                }
 
-               public static bool operator == (CustomAttributeTypedArgument obj1, CustomAttributeTypedArgument obj2)
+               public static bool operator == (CustomAttributeTypedArgument left, CustomAttributeTypedArgument right)
                {
-                       return obj1.Equals (obj2);
+                       return left.Equals (right);
                }
 
-               public static bool operator != (CustomAttributeTypedArgument obj1, CustomAttributeTypedArgument obj2)
+               public static bool operator != (CustomAttributeTypedArgument left, CustomAttributeTypedArgument right)
                {
-                       return !obj1.Equals (obj2);
+                       return !left.Equals (right);
                }
        }