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 [EMAIL PROTECTED]

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

--- shadow/81046        2007-03-06 01:50:48.000000000 -0500
+++ shadow/81046.tmp.11570      2007-03-06 01:50:48.000000000 -0500
@@ -0,0 +1,75 @@
+Bug#: 81046
+Product: Mono: Class Libraries
+Version: 1.0
+OS: other
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Wishlist
+Component: System
+AssignedTo: [EMAIL PROTECTED]                            
+ReportedBy: [EMAIL PROTECTED]               
+QAContact: [EMAIL PROTECTED]
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: [System.Collections.Generic.List<T>] List<T>.set_Item(int index) 
throws inappropriate exception when index is equal to List<T>.Count
+
+Please fill in this template when reporting a bug, unless you know what you 
are doing.
+Description of Problem:
+30 lines of code are worth a thousand words, right?
+
+using System;
+using System.Collections.Generic;
+
+namespace MonoBug
+{
+       public class ListBug
+       {
+               public static void Main()
+               {
+                       List<string> myList = new List<string>();
+                       
+                       try {
+                               myList[0] = "foo";
+                       }
+                       catch (Exception e) {
+                               Console.WriteLine(e);
+                       }
+                       
+                       IList<string> listReference = myList;
+                       
+                       try {
+                               listReference[0] = "foo";
+                       }
+                       catch (Exception e) {
+                               Console.WriteLine(e);
+                       }
+               }
+       }
+}
+
+The above code ought to throw to ArgumentOutOfRangeExceptions, but under Mono, 
they throw 
+IndexOutOfRangeExceptions, instead.
+
+Steps to reproduce the problem:
+1. Compile the above code
+2. Run it
+3. Watch and see
+
+Actual Results:
+You get two IndexOutOfRangeExceptions
+
+Expected Results:
+You should get two ArgumentOutOfRangeExceptions
+
+How often does this happen? 
+Always
+
+Additional Information:
+This occurs because set_Item calls CheckIndex, which does not check to 
determine if index is 
+equal to _size (because in most of the contexts from which CheckIndex is 
called, this is 
+appropriate).
+
+The fix is simple, and will be attached momentarily.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to