From ca925e0c9b23443066f8a2a5072cc037a8c65e34 Mon Sep 17 00:00:00 2001 From: Paolo Molaro Date: Tue, 9 Apr 2002 07:22:59 +0000 Subject: [PATCH] Tue Apr 9 13:12:09 CEST 2002 Paolo Molaro * MonoCustomAttrs.cs: return arrays of type Attribute[] instead of object[]. svn path=/trunk/mcs/; revision=3710 --- mcs/class/corlib/System/ChangeLog | 6 ++++++ mcs/class/corlib/System/MonoCustomAttrs.cs | 8 +++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/mcs/class/corlib/System/ChangeLog b/mcs/class/corlib/System/ChangeLog index 20b5db3897b..7c481a52d3e 100644 --- a/mcs/class/corlib/System/ChangeLog +++ b/mcs/class/corlib/System/ChangeLog @@ -1,3 +1,9 @@ + +Tue Apr 9 13:12:09 CEST 2002 Paolo Molaro + + * MonoCustomAttrs.cs: return arrays of type Attribute[] + instead of object[]. + 2002/04/09 Nick Drochak * String.cs (Substring): Copy only non-null characters to the new diff --git a/mcs/class/corlib/System/MonoCustomAttrs.cs b/mcs/class/corlib/System/MonoCustomAttrs.cs index 3ed54c9e34c..c8b874c5932 100755 --- a/mcs/class/corlib/System/MonoCustomAttrs.cs +++ b/mcs/class/corlib/System/MonoCustomAttrs.cs @@ -32,18 +32,20 @@ namespace System { object[] res = from_cache (obj); // shortcut if (res.Length == 1 && res[0].GetType () == attributeType) - return res; + return (object[])res.Clone (); ArrayList a = new ArrayList (); foreach (object attr in res) { if (attributeType.Equals (attr.GetType ())) a.Add (attr); } - return a.ToArray (); + Attribute[] r = new Attribute [a.Count]; + a.CopyTo (r); + return r; } internal static object[] GetCustomAttributes (ICustomAttributeProvider obj, bool inherit) { // handle inherit - return from_cache (obj); + return (Object[])from_cache (obj).Clone (); } internal static bool IsDefined (ICustomAttributeProvider obj, Type attributeType, bool inherit) { // handle inherit -- 2.25.1