[Mono-dev] [PATCH] Fixes for System.Collections.Generic.ICollection<T>.CopyTo

Pia Eriksson pe at hallerud.se
Wed May 6 17:16:58 EDT 2009


Hi,

I was porting some .net code to mono and ran into issues with CopyTo on
classes in System.Collections.Generic. Some implementations works as
documented, others don't. To be specific, the problem it's what happens
when you call CopyTo on an empty collection.

Docs:
http://msdn.microsoft.com/en-us/library/0efx51xw.aspx

Check out the condition for ArgumentException. My interpretation is that
nothing should happen if the collection is empty, but mono throws
ArgumentException. MS implementations does not. The key issue here is
consistency. As I said, some classes (ex. Stack) works as expected already. 
In corlib's Dictionary we have:
// we want no exception for index==array.Length && Count == 0

I don't think we need an argument about what's correct :-) There is a bugzilla
bug #497720 also, but it only mentions one of the problems that needs a patch.

Since I don't have (and don't want or need) svn access I leave the following
patches in your hands. Please review and then commit if accepted:

generic.diff:
Actual code fixes for the collections that don't work as expected

generic_test.diff:
Updated tests for Collections.Geneneric. Existing tests for CopyTo updated
with a test for the problem described. If no test existed, new ones written.

Keep up the good work!

/Pia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generic_test.diff
Type: text/x-patch
Size: 6532 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090506/f593ad54/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: generic.diff
Type: text/x-patch
Size: 2978 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20090506/f593ad54/attachment-0001.bin 


More information about the Mono-devel-list mailing list