https://bugzilla.novell.com/show_bug.cgi?id=664839
https://bugzilla.novell.com/show_bug.cgi?id=664839#c0 Summary: PropertyManager property change doesn't update child binding managers Classification: Mono Product: Mono: Class Libraries Version: 2.6.x Platform: x86 OS/Version: Windows 7 Status: NEW Severity: Normal Priority: P5 - None Component: Windows.Forms AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1036 Safari/532.5 When the property of a parent PropertyManager changes, the child binding managers don't update. Reproducible: Always Steps to Reproduce: [Test] public void Test_WhenParent_PropertyManager_PropertyChanges() { TestDataSourceWithRelatedObjects obj = new TestDataSourceWithRelatedObjects(); obj.ObjProperty = new TestDataSource { List = new BindingList<TestDataSource> { new TestDataSource { IntProperty = 1 } } }; BindingContext bc = new BindingContext(); PropertyManager parentBindingManager = (PropertyManager)bc[obj, "ObjProperty"]; BindingManagerBase bm = bc[obj, "ObjProperty.List"]; AssertEquals(1, ((TestDataSource)bm.Current).IntProperty, "Initial value of ObjProperty.List[0].IntProperty"); obj.ObjProperty = new TestDataSource { List = new BindingList<TestDataSource> { new TestDataSource { IntProperty = 2 } } }; AssertEquals(2, ((TestDataSource)bm.Current).IntProperty, "Value of ObjProperty.List[0].IntProperty"); } class TestDataSourceWithRelatedObjects { public BindingList<TestDataSource> List { get; set; } } class TestDataSource { public event EventHandler IntPropertyChanged; public const int IntPropertyDefaultValue = 5; int intProperty = IntPropertyDefaultValue; public int IntProperty { get { return intProperty; } set { intProperty = value; if (IntPropertyChanged != null) { IntPropertyChanged(this, EventArgs.Empty); } } } } Actual Results: Unit test fails. Expected Results: The unit test should pass, as it does with ms.net. These changes fix the issue and cause the above unit test to pass: Code modified in RelatedCurrencyManager constructor: public RelatedCurrencyManager (BindingManagerBase parent, PropertyDescriptor prop_desc) : base (prop_desc.GetValue (parent.Current)) { this.parent = parent; this.prop_desc = prop_desc; parent.CurrentItemChanged += new EventHandler(parent_CurrentItemChanged); // line added //parent.PositionChanged += new EventHandler(parent_PositionChanged); // line removed - PositionChanged is never fired from a PropertyManager } Code modified in RelatedCurrencyManager.parent_PositionChanged: private void parent_CurrentItemChanged(object sender, EventArgs args) // line added //private void parent_PositionChanged (object sender, EventArgs args) // line removed { if (parent.Position == -1) return; // line added to prevent IndexOutOfRangeException SetDataSource (prop_desc.GetValue (parent.Current)); } Code modified in PropertyManager.OnCurrentChanged: protected internal override void OnCurrentChanged (EventArgs ea) { PushData (); if (onCurrentChangedHandler != null) { onCurrentChangedHandler (this, ea); } // CurrentChanged implies CurrentItemChanged here // line added if (onCurrentItemChangedHandler != null) // line added { // line added onCurrentItemChangedHandler(this, ea); // line added } // line added } Code modified in ListBindingHelper.GetListItemProperties: public static PropertyDescriptorCollection GetListItemProperties (object list, PropertyDescriptor [] listAccessors) { list = GetList (list); if (list == null) return new PropertyDescriptorCollection (null); if (list is ITypedList) return ((ITypedList)list).GetItemProperties (listAccessors); if (listAccessors == null || listAccessors.Length == 0) { Type item_type = GetListItemType (list); return TypeDescriptor.GetProperties (item_type, new Attribute [] { new BrowsableAttribute (true) }); } // Take into account only the first property Type property_type = listAccessors[listAccessors.Length - 1].PropertyType; // line added //Type property_type = listAccessors [0].PropertyType; // line removed if (typeof (IList).IsAssignableFrom (property_type) #if NET_2_0 || typeof (IList<>).IsAssignableFrom (property_type) #endif ) { PropertyInfo property = GetPropertyByReflection (property_type, "Item"); return TypeDescriptor.GetProperties (property.PropertyType); } return TypeDescriptor.GetProperties(property_type); // line added //return new PropertyDescriptorCollection (new PropertyDescriptor [0]); // line removed } -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
