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
diff options
context:
space:
mode:
authorLeonard <leonard.r.koenig@googlemail.com>2019-10-25 20:30:08 +0300
committerAlexander Köplinger <alex.koeplinger@outlook.com>2019-10-25 20:30:08 +0300
commit4ec9bd03e509c610c95cd538c26091b873276491 (patch)
treec2f3c3e1fc1699d1329ca39eb30fe6bc26d58ca1 /mcs/class/System.Windows.Forms
parent1bd76c6069f347a5596d98d40a2a76111639e958 (diff)
Fixes #17190: SerializationException on ListViewItemCount (#17195)
* Fix issue #17190: SerializationException on ListViewItemCount ListViewGroup doesn't (always) have a serialized member "ListViewItemCount". This patch accounts for that and also adds support for the "ItemsCount" property that upstream [1] seems to use. Also items should be initialized regardless of the count, otherwise we get a NPE. [1] https://github.com/dotnet/winforms/blob/master/src/System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.cs#L144
Diffstat (limited to 'mcs/class/System.Windows.Forms')
-rw-r--r--mcs/class/System.Windows.Forms/System.Windows.Forms/ListViewGroup.cs22
1 files changed, 15 insertions, 7 deletions
diff --git a/mcs/class/System.Windows.Forms/System.Windows.Forms/ListViewGroup.cs b/mcs/class/System.Windows.Forms/System.Windows.Forms/ListViewGroup.cs
index 5d757d2c350..4386bca1fa5 100644
--- a/mcs/class/System.Windows.Forms/System.Windows.Forms/ListViewGroup.cs
+++ b/mcs/class/System.Windows.Forms/System.Windows.Forms/ListViewGroup.cs
@@ -84,15 +84,23 @@ namespace System.Windows.Forms
header_alignment = (HorizontalAlignment)info.GetInt32("HeaderAlignment");
tag = info.GetValue("Tag", typeof(object));
- int count = info.GetInt32("ListViewItemCount");
- if (count > 0) {
- if(items == null)
+ int count = 0;
+ try {
+ count = info.GetInt32("ItemsCount");
+ } catch (SerializationException e) {
+ // Mono backwards compat
+ try {
+ count = info.GetInt32("ListViewItemCount");
+ } catch (SerializationException e2) {}
+ }
+
+ if (items == null) {
items = new ListView.ListViewItemCollection(list_view_owner);
+ }
- for (int i = 0; i < count; i++)
- {
- items.Add((ListViewItem)info.GetValue(string.Format("ListViewItem_{0}", i), typeof(ListViewItem)));
- }
+ for (int i = 0; i < count; i++)
+ {
+ items.Add((ListViewItem)info.GetValue(string.Format("ListViewItem_{0}", i), typeof(ListViewItem)));
}
}