Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2014-01-13 18:24:13 +0400
committerMarek Safar <marek.safar@gmail.com>2014-01-13 18:24:13 +0400
commit5359f9feaf83d990722d3e0e0b583802704170fe (patch)
treebfa879eb3eeee1879435a02b53019823307de8ac /mcs/class
parenta41fe9781b9db46c02af404910ddc0174546036d (diff)
parent7a5ab1d8c9df6a62a04ae2efb4c27ce7933d9e63 (diff)
Merge pull request #844 from scottmcarthur/master
Check for null item in BindingList<T>.InsertItem
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/System/System.ComponentModel/BindingList.cs2
-rw-r--r--mcs/class/System/Test/System.ComponentModel/BindingListTest.cs10
2 files changed, 11 insertions, 1 deletions
diff --git a/mcs/class/System/System.ComponentModel/BindingList.cs b/mcs/class/System/System.ComponentModel/BindingList.cs
index b64d655efe0..b4c0ce8b69b 100644
--- a/mcs/class/System/System.ComponentModel/BindingList.cs
+++ b/mcs/class/System/System.ComponentModel/BindingList.cs
@@ -242,7 +242,7 @@ namespace System.ComponentModel {
if (raise_list_changed_events)
OnListChanged (new ListChangedEventArgs (ListChangedType.ItemAdded, index));
- if (type_raises_item_changed_events)
+ if (item != null && type_raises_item_changed_events)
(item as INotifyPropertyChanged).PropertyChanged += Item_PropertyChanged;
}
diff --git a/mcs/class/System/Test/System.ComponentModel/BindingListTest.cs b/mcs/class/System/Test/System.ComponentModel/BindingListTest.cs
index 88be568f429..92a6253db91 100644
--- a/mcs/class/System/Test/System.ComponentModel/BindingListTest.cs
+++ b/mcs/class/System/Test/System.ComponentModel/BindingListTest.cs
@@ -629,6 +629,16 @@ namespace MonoTests.System.ComponentModel
Assert.IsTrue (added, "ItemAdded");
Assert.IsTrue (changed, "ItemChanged");
}
+
+ [Test] // https://bugzilla.xamarin.com/show_bug.cgi?id=16902
+ public void Bug16902 ()
+ {
+ var list = new BindingList<Item> ();
+ list.Insert (0, null);
+ var count = list.Count;
+
+ Assert.AreEqual (1, count, "1");
+ }
}
}