2008-05-05 Ivan N. Zlatev <contact@i-nz.net>
authorIvan Zlatev <ivan@ivanz.com>
Mon, 5 May 2008 15:48:48 +0000 (15:48 -0000)
committerIvan Zlatev <ivan@ivanz.com>
Mon, 5 May 2008 15:48:48 +0000 (15:48 -0000)
* TypeDescriptor.cs: GetProperties should not return write-only
properties. Patch by James Fitzsimons  <james.fitzsimons@gmail.com>.
  * TypeDescriptorTests.cs: Add test for handling write-only properties.

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

mcs/class/System/System.ComponentModel/ChangeLog
mcs/class/System/System.ComponentModel/TypeDescriptor.cs
mcs/class/System/Test/System.ComponentModel/ChangeLog
mcs/class/System/Test/System.ComponentModel/TypeDescriptorTests.cs

index 6b83a55258c3cb763ed2baf35fae5929a5eda25b..08ea0c09106be47b33b8950b7482af4a17560df2 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-05  James Fitzsimons <james.fitzsimons@gmail.com>
+
+       * TypeDescriptor.cs: GetProperties should not return write-only 
+       properties.
+
 2008-04-26  Jb Evain  <jbevain@novell.com>
 
        * PropertyTabAttribute.cs, BindingList.cs: replace
index 50607e0f0eef25dc8ed2ab35a5cd49d015c49a7a..b2e45ffb2773d9da8e24b5c8b45783c078f22174 100644 (file)
@@ -1108,6 +1108,7 @@ public sealed class TypeDescriptor
                                PropertyInfo[] props = currentType.GetProperties (BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly);
                                foreach (PropertyInfo property in props) {
                                        if (property.GetIndexParameters ().Length == 0 &&
+                                           property.CanRead &&
                                            !propertiesHash.ContainsKey (property.Name)) {
                                                propertiesList.Add (new ReflectionPropertyDescriptor (property));
                                                propertiesHash.Add (property.Name, null);
index f3deff1d920a481e818e2beccc31fdf8e8e1b990..35a889873e4e19e52193de3ce5aa8f7fb264152b 100644 (file)
@@ -1,3 +1,8 @@
+2008-05-05  Ivan N. Zlatev  <contact@i-nz.net>
+
+       * TypeDescriptorTests.cs: Add test for handling write-only properties.
+       Based on patch by James Fitzsimons <james.fitzsimons@gmail.com>
+
 2008-04-30  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * ComponentConverterTests.cs: Allow test to be compiled using csc 1.x.
index 68e57aa44581b42408ec58ecee7108d9b8df35fb..0494fa37cfdb3908c1e493a1ae516a187a83c35f 100644 (file)
@@ -255,6 +255,10 @@ namespace MonoTests.System.ComponentModel
                internal int Height {
                        get { return 0; }
                }
+
+               public string WriteOnlyProperty {
+                       set { prop = value; }
+               }
        }
 
        [DescriptionAttribute ("my test derived component")]
@@ -786,6 +790,10 @@ namespace MonoTests.System.ComponentModel
                        // (Type.GetProperties does return both properties)
                        //
                        Assert.AreEqual (1, yetAnotherPropsFound, "#G3");
+
+                       // GetProperties does not return write-only properties (ones without a getter)
+                       // 
+                       Assert.IsNull (col.Find ("WriteOnlyProperty", true), "#H1");
                }
 
                [Test]