[Mono-bugs] [Bug 82492][Nor] New - SortedList::Keys throws when empty

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Aug 19 21:22:44 EDT 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by jesjones at mindspring.com.

http://bugzilla.ximian.com/show_bug.cgi?id=82492

--- shadow/82492	2007-08-19 21:22:44.000000000 -0400
+++ shadow/82492.tmp.13270	2007-08-19 21:22:44.000000000 -0400
@@ -0,0 +1,74 @@
+Bug#: 82492
+Product: Mono: Class Libraries
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: System
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: jesjones at mindspring.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: SortedList::Keys throws when empty
+
+Description of Problem:
+SortedList::Keys throws with 1.2.5 if the list is empty. MSDN doesn't seem
+to say anything about this so I think it's a bug.
+
+Steps to reproduce the problem:
+Run the code below.
+
+Actual Results:
+Get a ArgumentOutOfRangeException.
+
+Expected Results:
+No exceptions.
+
+How often does this happen? 
+Always
+
+Additional Information:
+
+---- snip ----------------------
+using System;
+using System.Collections.Generic;
+
+public class Program
+{
+    public static void Main(string[] args)
+    {         
+        var sorted1 = new SortedList<string, int>();
+        sorted1.Add("one", 1);
+
+        var sorted0 = new SortedList<string, int>();
+        
+        var list1 = new List<string>();
+        list1.AddRange(sorted1.Keys);
+        Console.WriteLine("list1 = [{0}]", string.Join(", ", list1.ToArray()));
+        
+        var list0 = new List<string>();
+        list0.AddRange(sorted0.Keys);      // Argument is out of range
+exception here
+        Console.WriteLine("list0 = [{0}]", string.Join(", ", list0.ToArray()));
+    }
+} 
+
+// Unhandled Exception: System.ArgumentOutOfRangeException: Argument is out
+of range.
+// Parameter name: arrayIndex is greater than or equal to array.Length
+//   at
+System.Collections.Generic.SortedList`2+ListKeys[System.String,System.Int32].CopyTo
+(System.String[] , Int32 ) [0x0007e] in
+mono-1.2.5/mcs/class/System/System.Collections.Generic/SortedList.cs:843 
+//   at System.Collections.Generic.List`1[System.String].AddCollection
+(ICollection`1 ) [0x0000e] in
+mono-1.2.5/mcs/class/corlib/System.Collections.Generic/List.cs:116 
+//   at System.Collections.Generic.List`1[System.String].AddRange
+(IEnumerable`1 ) [0x00015] in
+mono-1.2.5/mcs/class/corlib/System.Collections.Generic/List.cs:133 
+//   at Program.Main (System.String[] args) [0x00000]


More information about the mono-bugs mailing list