Author: gonzalo
Date: 2006-09-11 12:45:06 -0400 (Mon, 11 Sep 2006)
New Revision: 65242

Modified:
   trunk/mcs/class/System/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
   trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
   trunk/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs
Log:
2006-09-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>

        * Test/System.ComponentModel/TypeDescriptorTests.cs: test for overriden
        attributes.
        * System.ComponentModel/TypeDescriptor.cs: don't ignore toplevel
        attributes when they are overriden.

        Patch by Ivan N. Zlatev that fixes bug #79256.



Modified: trunk/mcs/class/System/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/ChangeLog      2006-09-11 
16:30:25 UTC (rev 65241)
+++ trunk/mcs/class/System/System.ComponentModel/ChangeLog      2006-09-11 
16:45:06 UTC (rev 65242)
@@ -1,3 +1,10 @@
+2006-09-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * TypeDescriptor.cs: don't ignore toplevel attributes when they are
+       overriden.
+
+       Patch by Ivan N. Zlatev that fixes bug #79256.
+
 2006-08-20  Gert Driesen  <[EMAIL PROTECTED]>
 
        * InvalidEnumArgumentException.cs: Beautify error message.

Modified: trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs
===================================================================
--- trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs      
2006-09-11 16:30:25 UTC (rev 65241)
+++ trunk/mcs/class/System/System.ComponentModel/TypeDescriptor.cs      
2006-09-11 16:45:06 UTC (rev 65242)
@@ -705,8 +705,13 @@
                        bool cache = true;
                        object[] ats = _infoType.GetCustomAttributes (true);
                        Hashtable t = new Hashtable ();
-                       foreach (Attribute at in ats)
-                               t [at.TypeId] = at;
+
+                       // Filter the custom attributes, so that only the top
+                       // level of the same type are left.
+                       //
+                       for (int i = ats.Length -1; i >= 0; i--) {
+                               t [((Attribute) ats[i]).TypeId] = ats[i];
+                       }
                                        
                        if (comp != null && comp.Site != null) 
                        {

Modified: trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2006-09-11 
16:30:25 UTC (rev 65241)
+++ trunk/mcs/class/System/Test/System.ComponentModel/ChangeLog 2006-09-11 
16:45:06 UTC (rev 65242)
@@ -1,3 +1,8 @@
+2006-09-11 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
+
+       * TypeDescriptorTests.cs: test for overriden attributes.
+       Patch by Ivan N. Zlatev.
+
 2006-05-22  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
        * TypeDescriptorTest.cs : added GetPropertiesIgnoreIndexers().

Modified: 
trunk/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs
===================================================================
--- trunk/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs    
2006-09-11 16:30:25 UTC (rev 65241)
+++ trunk/mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs    
2006-09-11 16:45:06 UTC (rev 65242)
@@ -32,6 +32,19 @@
                public void Dispose () { }
        }
 
+       class MyOtherDesigner: IDesigner
+       {
+               public MyOtherDesigner()
+               {
+               }
+
+               public IComponent Component {get {return null; } }
+               public DesignerVerbCollection Verbs { get {return null; } }
+               public void DoDefaultAction () { }
+               public void Initialize (IComponent component) { }
+               public void Dispose () { }
+       }
+       
        class MySite: ISite
        { 
                public IComponent Component { get {  return null; } }
@@ -136,7 +149,7 @@
                }
                
                [DescriptionAttribute ("test")]
-               public string TestProperty
+               public virtual string TestProperty
                {
                        get { return prop; }
                        set { prop = value; }
@@ -149,6 +162,29 @@
                }
        }
 
+       [DescriptionAttribute ("my test derived component")]
+       [DesignerAttribute (typeof(MyOtherDesigner))]
+       public class MyDerivedComponent: MyComponent
+       {
+               string prop;
+               
+               public MyDerivedComponent  ()
+               {
+               }
+               
+               public MyDerivedComponent (ISite site) : base (site)
+               {
+               }
+               
+               [DescriptionAttribute ("test derived")]
+               public override string TestProperty
+               {
+                       get { return prop; }
+                       set { prop = value; }
+               }
+       }
+       
+
        [DefaultProperty("AnotherProperty")]
        [DefaultEvent("AnotherEvent")]
        [DescriptionAttribute ("my test component")]
@@ -256,6 +292,13 @@
                        Assert ("t10", col[typeof(DescriptionAttribute)] != 
null);
                        Assert ("t11", col[typeof(DesignerAttribute)] != null);
                        Assert ("t12", col[typeof(EditorAttribute)] != null);
+
+                       col = TypeDescriptor.GetAttributes (typeof 
(MyDerivedComponent));
+                       Assert ("t13", col[typeof(DesignerAttribute)] != null);
+                       Assert ("t14", col[typeof(DescriptionAttribute)] != 
null);
+                       DesignerAttribute attribute = 
col[typeof(DesignerAttribute)] as DesignerAttribute;
+                       Assert ("t15", attribute != null);
+                       AssertEquals ("t16", attribute.DesignerTypeName, 
typeof(MyOtherDesigner).AssemblyQualifiedName);
                }
                
                [Test]

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to