[Mono-bugs] [Bug 47307][Nor] New - CollectionBase.Add does not undo the added element when OnInsertComplete throws an exception
bugzilla-daemon@rocky.ximian.com
bugzilla-daemon@rocky.ximian.com
Sun, 3 Aug 2003 14:48:24 -0400 (EDT)
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 barce@frlp.utn.edu.ar.
http://bugzilla.ximian.com/show_bug.cgi?id=47307
--- shadow/47307 Sun Aug 3 14:48:24 2003
+++ shadow/47307.tmp.30338 Sun Aug 3 14:48:24 2003
@@ -0,0 +1,77 @@
+Bug#: 47307
+Product: Mono/Class Libraries
+Version: unspecified
+OS: All
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Normal
+Component: CORLIB
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: barce@frlp.utn.edu.ar
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: CollectionBase.Add does not undo the added element when OnInsertComplete throws an exception
+
+Description of Problem:
+
+Neither CollectionBase.Add nor CollectionBase.Insert undo the added element
+when OnInsertComplete throws an exception.
+.NET Framework deletes the new Item, mono does not.
+
+Since this is a NON-ECMA class, Mono should mimic the .NET behaviour.
+
+Steps to reproduce the problem:
+Compile and run this:
+
+using System;
+using System.Collections;
+
+namespace PruebaBugCollectionBase
+{
+ class MyCollection: CollectionBase
+ {
+ public int Add(int number)
+ {
+ return List.Add(number);
+ }
+
+ protected override void OnInsertComplete(int index, object value)
+ {
+ throw new ApplicationException("my exception in OnInsertComplete");
+ }
+
+ }
+
+ class Class1
+ {
+ static void Main(string[] args)
+ {
+ MyCollection c = new MyCollection();
+ try
+ {
+ c.Add(10);
+ }
+ finally
+ {
+ Console.WriteLine("Count: {0}", c.Count);
+ Console.ReadLine();
+ }
+ }
+ }
+}
+
+Actual Results:
+Count: 1
+
+Expected Results:
+Count: 0
+
+using System;
+using System.Collections;
+
+How often does this happen?
+Always