Merge pull request #2488 from nealef/master
[mono.git] / mcs / class / corlib / System.Reflection / CustomAttributeData.cs
index 3adbbb96435aa696ccbbac57557585aaaa6cde08..d884714401b27c3fcad2e58eacdde330a594f1aa 100644 (file)
@@ -37,11 +37,7 @@ namespace System.Reflection {
 
        [ComVisible (true)]
        [Serializable]
-#if NET_4_0
        public
-#else
-       public sealed
-#endif
        class CustomAttributeData {
                class LazyCAttrData {
                        internal Assembly assembly;
@@ -55,11 +51,9 @@ namespace System.Reflection {
                LazyCAttrData lazyData;
 
 
-#if NET_4_0
                protected CustomAttributeData ()
                {
                }
-#endif
 
                internal CustomAttributeData (ConstructorInfo ctorInfo, Assembly assembly, IntPtr data, uint data_length)
                {
@@ -91,9 +85,7 @@ namespace System.Reflection {
                
                [ComVisible (true)]
                public
-#if NET_4_0
                virtual
-#endif
                ConstructorInfo Constructor {
                        get {
                                return ctorInfo;
@@ -102,9 +94,7 @@ namespace System.Reflection {
 
                [ComVisible (true)]
                public
-#if NET_4_0
                virtual
-#endif
                IList<CustomAttributeTypedArgument> ConstructorArguments {
                        get {
                                ResolveArguments ();
@@ -113,9 +103,7 @@ namespace System.Reflection {
                }
 
                public
-#if NET_4_0
                virtual
-#endif
                IList<CustomAttributeNamedArgument> NamedArguments {
                        get {
                                ResolveArguments ();
@@ -131,6 +119,10 @@ namespace System.Reflection {
                        return MonoCustomAttrs.GetCustomAttributesData (target);
                }
 
+               internal static IList<CustomAttributeData> GetCustomAttributesInternal (RuntimeType target) {
+                       return MonoCustomAttrs.GetCustomAttributesData (target);
+               }
+
                public static IList<CustomAttributeData> GetCustomAttributes (Module target) {
                        return MonoCustomAttrs.GetCustomAttributesData (target);
                }
@@ -139,14 +131,14 @@ namespace System.Reflection {
                        return MonoCustomAttrs.GetCustomAttributesData (target);
                }
 
-#if NET_4_5
                public Type AttributeType {
                        get { return ctorInfo.DeclaringType; }
                }
-#endif
 
                public override string ToString ()
                {
+                       ResolveArguments ();
+
                        StringBuilder sb = new StringBuilder ();
 
                        sb.Append ("[" + ctorInfo.DeclaringType.FullName + "(");
@@ -203,13 +195,18 @@ namespace System.Reflection {
 
                public override int GetHashCode ()
                {
-                       int ret = ctorInfo.GetHashCode () << 16;
+                       int ret = ctorInfo == null ? 13 : (ctorInfo.GetHashCode () << 16);
                        // argument order-dependent
-                       for (int i = 0; i < ctorArgs.Count; i++)
-                               ret += ret ^ 7 + ctorArgs [i].GetHashCode () << (i * 4);
+                       if (ctorArgs != null) {
+                               for (int i = 0; i < ctorArgs.Count; i++) {
+                                       ret += ret ^ 7 + ctorArgs [i].GetHashCode () << (i * 4);
+                               }
+                       }
                        // argument order-independent
-                       for (int i = 0; i < namedArgs.Count; i++)
-                               ret += (namedArgs [i].GetHashCode () << 5);
+                       if (namedArgs != null) {
+                               for (int i = 0; i < namedArgs.Count; i++)
+                                       ret += (namedArgs [i].GetHashCode () << 5);
+                       }
                        return ret;
                }
        }