2
0
Эх сурвалжийг харах

2007-08-19 Ivan N. Zlatev <[email protected]>

        * ReflectionPropertyDescriptor.cs: For read-only properties,
        ShouldSerializeValue must also check for 
        DesignerSerializationVisibility.Content and if present return
true.
        * PropertyDescriptorTests.cs: Tests to verify the above.


svn path=/trunk/mcs/; revision=84402
Ivan Zlatev 18 жил өмнө
parent
commit
280c2da733

+ 6 - 0
mcs/class/System/System.ComponentModel/ChangeLog

@@ -1,3 +1,9 @@
+2007-08-19  Ivan N. Zlatev  <[email protected]>
+
+	* ReflectionPropertyDescriptor.cs: For read-only properties,
+	ShouldSerializeValue must also check for 
+	DesignerSerializationVisibility.Content and if present return true.
+
 2007-08-19  Ivan N. Zlatev  <[email protected]>
 
 	* EnumConverter.cs: Implement conversion to and from Enum[]

+ 1 - 1
mcs/class/System/System.ComponentModel/ReflectionPropertyDescriptor.cs

@@ -231,7 +231,7 @@ namespace System.ComponentModel
 				MethodInfo mi = FindPropertyMethod (component, "ShouldSerialize");
 				if (mi != null)
 					return (bool) mi.Invoke (component, null);
-				return false;
+				return Attributes.Contains (DesignerSerializationVisibilityAttribute.Content);
 			}
 
 			DefaultValueAttribute attrib = ((DefaultValueAttribute) Attributes[typeof (DefaultValueAttribute)]);

+ 6 - 0
mcs/class/System/Test/System.ComponentModel/ChangeLog

@@ -1,3 +1,9 @@
+2007-08-19  Ivan N. Zlatev  <[email protected]>
+
+	* ReflectionPropertyDescriptorTests.cs: For read-only properties,
+	ShouldSerializeValue must also check for 
+	DesignerSerializationVisibility.Content and if present return true.
+
 2007-08-19  Gert Driesen  <[email protected]>
 
 	* TypeDescriptorTests: Removed Ivan's local Category.

+ 24 - 0
mcs/class/System/Test/System.ComponentModel/PropertyDescriptorTests.cs

@@ -193,6 +193,18 @@ namespace MonoTests.System.ComponentModel
 				set { _prop7 = value; }
 			}
 
+			[ReadOnly (true)]
+			[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+			public string Prop8 {
+				get { return null; }
+			}
+
+			[ReadOnly (true)]
+			[DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
+			public string Prop9 {
+				get { return null; }
+			}
+
 			public bool SerializeProp3 {
 				get { return _serializeProp3; }
 				set { _serializeProp3 = value; }
@@ -243,6 +255,11 @@ namespace MonoTests.System.ComponentModel
 				return _serializeProp7;
 			}
 
+			public bool ShouldSerializeProp8 ()
+			{
+				return false;
+			}
+
 			private string _prop1;
 			private string _prop2;
 			private string _prop3;
@@ -412,6 +429,8 @@ namespace MonoTests.System.ComponentModel
 			PropertyDescriptor prop5PD = properties ["Prop5"];
 			PropertyDescriptor prop6PD = properties ["Prop6"];
 			PropertyDescriptor prop7PD = properties ["Prop7"];
+			PropertyDescriptor prop8PD = properties ["Prop8"];
+			PropertyDescriptor prop9PD = properties ["Prop9"];
 
 			Assert.IsFalse (prop1PD.ShouldSerializeValue (test), "#A1");
 			Assert.IsTrue (prop2PD.ShouldSerializeValue (test), "#A2");
@@ -448,6 +467,11 @@ namespace MonoTests.System.ComponentModel
 			Assert.IsTrue (prop7PD.ShouldSerializeValue (test), "#C7");
 			test.Prop7 = "good";
 			Assert.IsTrue (prop7PD.ShouldSerializeValue (test), "#C8");
+
+			// has both DesignerSerializationVisibility.Content and ShouldSerialize { return false }
+			Assert.IsFalse (prop8PD.ShouldSerializeValue (test), "#D1");
+			// has DesignerSerializationVisibility.Content, no ShouldSerialize
+			Assert.IsTrue (prop9PD.ShouldSerializeValue (test), "#D2");
 		}
 
 		[Test]