+2007-08-19 Ivan N. Zlatev <contact@i-nz.net>
+
+ * TypeDescriptor.cs: GetProperties should return only the last type's
+ implementation of a property with a matching name in the base types.
+
2007-08-03 Jb Evain <jbevain@novell.com>
* ComponentCollection.cs: use our own collection base
bool cache = true;
PropertyInfo[] props = _component.GetType().GetProperties (BindingFlags.Instance | BindingFlags.Public);
Hashtable t = new Hashtable ();
- foreach (PropertyInfo pr in props)
- t [pr.Name] = new ReflectionPropertyDescriptor (pr);
+ for (int i = props.Length-1; i >= 0; i--)
+ t [props[i].Name] = new ReflectionPropertyDescriptor (props[i]);
if (_component.Site != null)
{
return _properties;
PropertyInfo[] props = InfoType.GetProperties (BindingFlags.Instance | BindingFlags.Public);
- ArrayList descs = new ArrayList (props.Length);
- for (int n=0; n<props.Length; n++)
+ Hashtable descs = new Hashtable ();
+ for (int n= props.Length-1; n >= 0; n--)
if (props [n].GetIndexParameters ().Length == 0)
- descs.Add (new ReflectionPropertyDescriptor (props[n]));
+ descs[props[n].Name] = new ReflectionPropertyDescriptor (props[n]);
- _properties = new PropertyDescriptorCollection ((PropertyDescriptor[]) descs.ToArray (typeof (PropertyDescriptor)), true);
+ PropertyDescriptor[] descriptors = new PropertyDescriptor[descs.Values.Count];
+ descs.Values.CopyTo (descriptors, 0);
+ _properties = new PropertyDescriptorCollection (descriptors, true);
return _properties;
}
}
System.ComponentModel/UInt32ConverterTests.cs
System.ComponentModel/UInt64ConverterTests.cs
System.ComponentModel.Design/ServiceContainerTest.cs
+System.ComponentModel.Design.Serialization/ContextStackTest.cs
System.ComponentModel.Design.Serialization/InstanceDescriptorTest.cs
System.Configuration/ApplicationSettingsBaseTest.cs
System.Configuration/LocalFileSettingsProviderTest.cs
+2007-08-19 Ivan N. Zlatev <contact@i-nz.net>
+
+ * TypeDescriptorTest.cs: new test to verify that GetProperties returns
+ only the last type's implementation of a property with a matching name
+ in the base types.
+
2007-08-01 Atsushi Enomoto <atsushi@ximian.com>
* BackgroundWorkerTest.cs : new test to clear some doubts on impl.
get { return prop; }
set { prop = value; }
}
+
+
+ [DescriptionAttribute ("test derived")]
+ public new string AnotherProperty
+ {
+ get { return base.AnotherProperty; }
+ set { base.AnotherProperty = value; }
+ }
}
}
[TestFixture]
+ [NUnit.Framework.Category ("inz")]
public class TypeDescriptorTests
{
MyComponent com = new MyComponent ();
col = TypeDescriptor.GetProperties (nfscom, filter);
Assert.IsNotNull (col.Find ("TestProperty", true), "#F1");
Assert.IsNull (col.Find ("AnotherProperty", true), "#F2");
+
+
+ // GetProperties should return only the last type's implementation of a
+ // property with a matching name in the base types. E.g in the case where
+ // the "new" keyword is used.
+ //
+ PropertyDescriptorCollection derivedCol = TypeDescriptor.GetProperties (typeof(MyDerivedComponent));
+ Assert.IsNotNull (derivedCol["AnotherProperty"].Attributes[typeof (DescriptionAttribute)], "#G1");
+ int propsFound = 0;
+ foreach (PropertyDescriptor props in derivedCol)
+ if (props.Name == "AnotherProperty")
+ propsFound++;
+ Assert.AreEqual (1, propsFound, "#G2");
}
[Test]