2003-02-11 Gonzalo Paniagua Javier <gonzalo@ximian.com>
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 11 Feb 2003 15:30:50 +0000 (15:30 -0000)
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>
Tue, 11 Feb 2003 15:30:50 +0000 (15:30 -0000)
* MonoCustomAttrs.cs: return the correct array type in the short case.
Fixes bug #37818.

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

mcs/class/corlib/System/ChangeLog
mcs/class/corlib/System/MonoCustomAttrs.cs

index 04c0bfffaf3d0328adbc050a4af74f3001eb2596..96005bd6e3a9dc20b4f60a181dfb708dedc33ead 100644 (file)
@@ -1,3 +1,8 @@
+2003-02-11  Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+       * MonoCustomAttrs.cs: return the correct array type in the short case.
+       Fixes bug #37818.
+
 2003-02-08  Pedro Martíenz Juliá  <yoros@wanadoo.es>
 
        * Math.cs: Fix a few methods (like Round) and add with comments the
index c7c43108c5edf5a73a0d916af5236d0e60c3b5a6..c1c783e303f412af3465ae354649195f0cac7e83 100755 (executable)
@@ -34,16 +34,17 @@ namespace System {
                internal static object[] GetCustomAttributes (ICustomAttributeProvider obj, Type attributeType, bool inherit)
                {
                        if (obj == null)
-                               return new object [0]; //FIXME: Should i throw an exception here?
+                               return (object []) Array.CreateInstance (attributeType, 0);
 
                        object[] r;
                        object[] res = from_cache (obj);
                        // shortcut
                        if (res.Length == 1) {
                                if (attributeType.IsAssignableFrom (res[0].GetType ())) {
-                                       r = new object [] {res [0]};
+                                       r = (object []) Array.CreateInstance (attributeType, 1);
+                                       r [0] = res [0];
                                } else {
-                                       r = new object [0];
+                                       r = (object []) Array.CreateInstance (attributeType, 0);
                                }
                                return r;
                        }