[Mono-bugs] [Bug 58270][Wis] New - remove_Event generates Delegate.Combine and not Delegate.Remove

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Mon, 10 May 2004 10:45:16 -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 malekith@pld-linux.org.

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

--- shadow/58270	2004-05-10 10:45:16.000000000 -0400
+++ shadow/58270.tmp.1078	2004-05-10 10:45:16.000000000 -0400
@@ -0,0 +1,57 @@
+Bug#: 58270
+Product: Mono: Compilers
+Version: unspecified
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 001 One hour
+Priority: Wishlist
+Component: C#
+AssignedTo: mono-bugs@ximian.com                            
+ReportedBy: malekith@pld-linux.org               
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: remove_Event generates Delegate.Combine and not Delegate.Remove
+
+This can be obsorved in following testcase:
+
+delegate void Foo ();
+class A {
+  public event Foo Bar;
+  public void go () { Bar (); }
+}
+ 
+class B {
+  public static void m1 ()
+  {
+        System.Console.WriteLine ("m1");
+  }
+ 
+  public static void Main ()
+  {
+    A a = new A();
+        a.Bar += new Foo (m1);
+        a.Bar -= new Foo (m1);
+        a.go ();
+  }
+}
+
+It should print nothing, but prints m1 twice. mono-0.91.
+
+Following patch for mcs fixes it (gmcs apperantly has it right):
+
+--- class.cs~   2004-05-10 16:17:42.235458977 +0200
++++ class.cs    2004-05-10 16:17:53.219100597 +0200
+@@ -5286,7 +5286,7 @@
+  
+                        protected override MethodInfo DelegateMethodInfo {
+                                get {
+-                                       return
+TypeManager.delegate_combine_delegate_delegate;
++                                       return
+TypeManager.delegate_remove_delegate_delegate;
+                                }
+                        }