Bug 318511 (MONO75545) - [PATCH] ArrayList:GetRange:ToArray ignores range index
Summary: [PATCH] ArrayList:GetRange:ToArray ignores range index
Status: RESOLVED FIXED
Alias: MONO75545
Product: Mono: Class Libraries
Classification: Mono
Component: CORLIB (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords: easy_fix, patch
Depends on:
Blocks:
 
Reported: 2005-07-14 04:39 UTC by Florian Groß
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Fix and test case. (1.56 KB, patch)
2005-07-14 04:39 UTC, Thomas Wiest
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:24:57 UTC


---- Reported by flgr@ccan.de 2005-07-13 21:39:17 MST ----

Description of Problem:

ArrayList:GetRange(index, count) is optimized. It returns a RangedArrayList
which just keeps a reference to the origin array list plus the index and
count arguments supplied to it.

However, RangedArrayList:ToArray (both with and without a type) does not
use its own index argument -- it always defaults to 0 instead. This is
evident in the following code:

char[] chars = {'a', 'b', 'c', 'd', 'e', 'f'};
ArrayList a = new ArrayList(chars);
ArrayList b = a.GetRange(3, 3);
object[] obj_chars = b.ToArray ();

obj_chars now refers to {'a', 'b', 'c'} instead of {'d', 'e', 'f'}.

Steps to reproduce the problem:
1. Run test case from patch.

Actual Results:

Index ignored, returns first count elements. (Here: {'a', 'b', 'c'})

Expected Results:

Index used, returns elements four through six. (Here: {'d', 'e', 'f'})

How often does this happen? 

Always.



---- Additional Comments From flgr@ccan.de 2005-07-13 21:39:52 MST ----

Created an attachment (id=168248)
Fix and test case.




---- Additional Comments From miguel@ximian.com 2005-07-15 10:55:42 MST ----

Florian, please commit both to SVN.



---- Additional Comments From bmaurer@users.sf.net 2005-07-31 17:40:25 MST ----

This was checked in a while ago...

Imported an attachment (id=168248)

Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>independent</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".