[Mono-bugs] [Bug 28306][Min] New - Delegate invocation works in reverse order

bugzilla-daemon@rocky.ximian.com bugzilla-daemon@rocky.ximian.com
29 Jul 2002 12:14:47 -0000


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 sergio.gomez@consejo-eps.uco.es.

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

--- shadow/28306	Mon Jul 29 08:14:47 2002
+++ shadow/28306.tmp.31626	Mon Jul 29 08:14:47 2002
@@ -0,0 +1,132 @@
+Bug#: 28306
+Product: Mono/Runtime
+Version: unspecified
+OS: Debian Woody
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Minor
+Component: misc
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: sergio.gomez@consejo-eps.uco.es               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Delegate invocation works in reverse order
+
+Description of Problem:
+
+Delegate invocation don't work correctly. The section 2.23 of ECMA334, says
+that:
+
+'Invocation of a delegate instance whose invocation list contains multiple
+entries, proceeds by invoking each of the methods in the invocation list,
+synchronously, in order.'
+
+However, mono run it in reverse order.
+
+Steps to reproduce the problem:
+
+// -- Example code:
+
+using System; 
+
+delegate void D(int x); 
+class Test  
+{ 
+  public static void M1(int i) { 
+   Console.WriteLine("Test.M1: " + i); 
+  } 
+ 
+  public static void M2(int i) { 
+   Console.WriteLine("Test.M2: " + i); 
+  } 
+
+  public void M3(int i) { 
+   Console.WriteLine("Test.M3: " + i); 
+  } 
+} 
+
+class Demo 
+{ 
+  static void Main() { 
+   D cd1 = new D(Test.M1); 
+   cd1(-1); // call M1 
+   D cd2 = new D(Test.M2); 
+   cd2(-2); // call M2 
+   D cd3 = cd1 + cd2; 
+   cd3(10); // call M1 then M2 
+
+   cd3 += cd1; 
+   cd3(20); // call M1, M2, then M1 
+   Test t = new Test(); 
+   D cd4 = new D(t.M3); 
+   cd3 += cd4; 
+   cd3(30); // call M1, M2, M1, then M3 
+   cd3 -= cd1; // remove last M1 
+   cd3(40); // call M1, M2, then M3 
+   cd3 -= cd4; 
+   cd3(50); // call M1 then M2 
+   cd3 -= cd2; 
+   cd3(60); // call M1 
+   cd3 -= cd2; // impossible removal is benign 
+   cd3(60); // call M1 
+   cd3 -= cd1; // invocation list is empty 
+   // cd3(70); // System.NullReferenceException thrown 
+   cd3 -= cd1; // impossible removal is benign 
+ }
+}
+
+Actual Results:
+sergio$ mono delegateinvocation.exe 
+Test.M1: -1
+Test.M2: -2
+Test.M2: 10
+Test.M1: 10
+Test.M1: 20
+Test.M2: 20
+Test.M1: 20
+Test.M3: 30
+Test.M1: 30
+Test.M2: 30
+Test.M1: 30
+Test.M3: 40
+Test.M2: 40
+Test.M1: 40
+Test.M2: 50
+Test.M1: 50
+Test.M1: 60
+Test.M1: 60
+
+Expected Results:
+
+sergio$ mono delegateinvocation.exe 
+Test.M1: -1
+Test.M2: -2
+Test.M1: 10
+Test.M2: 10
+Test.M1: 20
+Test.M2: 20
+Test.M1: 20
+Test.M1: 30
+Test.M2: 30
+Test.M1: 30
+Test.M3: 30
+Test.M1: 40
+Test.M2: 40
+Test.M3: 40
+Test.M1: 50
+Test.M2: 50
+Test.M1: 60
+Test.M1: 60
+
+How often does this happen? 
+
+Always
+
+Additional Information:
+
+sergio$ dpkg -s mono |grep Version
+Version: 0.13-20020727-1