From 3075fd979474e4674b60ca3b73e3b330e58aaf82 Mon Sep 17 00:00:00 2001 From: Jonathan Pobst Date: Tue, 15 Jul 2008 14:58:52 +0000 Subject: [PATCH] 2008-07-15 Jonathan Pobst * ImageList.cs: Fix ICollection.CopyTo implementation for ImageListCollection. [Fixes bug #409169] 2008-07-15 Jonathan Pobst * ImageListTest.cs: Add test for bug #409169. svn path=/trunk/mcs/; revision=107967 --- .../System.Windows.Forms/ChangeLog | 5 +++++ .../System.Windows.Forms/ImageList.cs | 3 +-- .../Test/System.Windows.Forms/ChangeLog | 4 ++++ .../Test/System.Windows.Forms/ImageListTest.cs | 16 ++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index a8303c5fc5f..c0d68ef4b13 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,8 @@ +2008-07-15 Jonathan Pobst + + * ImageList.cs: Fix ICollection.CopyTo implementation for + ImageListCollection. [Fixes bug #409169] + 2008-07-14 Jonathan Pobst * MenuAPI.cs, ToolStripDropDown.cs: Use VirtualScreen instead of diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs index 5956468450d..c78bd9c8c0a 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ImageList.cs @@ -949,8 +949,7 @@ namespace System.Windows.Forms void ICollection.CopyTo(Array dest, int index) { - for (int imageIndex = 0; imageIndex < this.Count; imageIndex++) - dest.SetValue (this [index], index++); + list.CopyTo (dest, index); } #endregion // ImageCollection Interface Methods } diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog index e4e083812d9..6e2ef1ff1ed 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog @@ -1,3 +1,7 @@ +2008-07-15 Jonathan Pobst + + * ImageListTest.cs: Add test for bug #409169. + 2008-07-14 Jonathan Pobst * TreeViewTest.cs: Add test for bug #409029. diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs index 3e8982e5b38..96c3cb0a931 100644 --- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs +++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ImageListTest.cs @@ -14,6 +14,7 @@ using System.Reflection; using System.ComponentModel; using NUnit.Framework; using System.Threading; +using System.Collections; namespace MonoTests.System.Windows.Forms @@ -169,6 +170,21 @@ namespace MonoTests.System.Windows.Forms myimagelist.ToString (), "#T3"); } + [Test] + public void Bug409169 () + { + ImageList imgList = new ImageList (); + ImageList.ImageCollection coll = imgList.Images; + Bitmap img1 = new Bitmap (10, 10); + coll.Add (img1); + + const int dstOffset = 5; + object[] dst = new object[dstOffset + coll.Count]; + ((IList)coll).CopyTo (dst, dstOffset); + + Assert.IsNotNull (dst[dstOffset], "A1"); + } + [TestFixture] public class ImageListRecreateHandleEventClass { -- 2.25.1