This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 36646 - Delegate.Remove for combined delegate works different from Microsoft .Net
Summary: Delegate.Remove for combined delegate works different from Microsoft .Net
Status: VERIFIED FIXED
Alias: None
Product: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC All
: --- normal
Target Milestone: (C6SR1)
Assignee: Ludovic Henry
URL:
Depends on:
Blocks:
 
Reported: 2015-12-05 07:44 UTC by Igor Kiselev
Modified: 2016-01-28 19:25 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Igor Kiselev 2015-12-05 07:44:47 UTC
Delegate.Remove with 4.2 updates changed behavior for combined delegate. It may be even better than was before, but it differs from Microsoft .Net.

Test case:
using System;
public static class Program
{
    public static void Main(string[] args)
    {
        Action a = A;
        Action b = B;
        Action c = C;
        Action s = a + b + c + Console.WriteLine;
        s();                  //ABC 
        (s - (a + c))();      //ABC 
    }

    public static void A()
    {
        Console.Write("A");
    }

    public static void B()
    {
        Console.Write("B");
    }

    public static void C()
    {
        Console.Write("C");
    }
}

Expected result:
ABC
ABC

Actual result:
ABC
B

Not sure, if it really needs to be fixed.
Comment 1 Ludovic Henry 2015-12-07 01:32:17 UTC
That clearly seems like a bug on the .NET side. I will check tomorrow what is the behaviour on windows.
Comment 2 Igor Kiselev 2015-12-07 01:43:37 UTC
Here is some information about it: https://confluence.jetbrains.com/plugins/servlet/mobile#content/view/42337747
Comment 3 Ludovic Henry 2015-12-07 04:17:54 UTC
Ok, thank you for the additional information. I will check the behaviour and implementation on .NET, and will fix it ASAP.

Thank you for the report!
Comment 5 Arpit Jha 2015-12-15 07:05:01 UTC
I have checked this issue with latest mono master MonoFramework-MDK-4.3.0.2063.macos10.xamarin.universal_dcb167189d14e2b55ccd128bfc2b5e5483ea0808 and its working fine .

Now getting following expected output in console on implementing code mentioned in console project.

ABC
ABC

Screencast : http://www.screencast.com/t/V6cPcEjYWe

Full Environment Info: https://gist.github.com/Arpit360/7894b76414dafa05a21b

Hence closing this issue.
Comment 6 Arpit Jha 2016-01-15 05:23:12 UTC
I have checked this issue latest C6SR1 Mono 4.2.2.28 and observed that on implementing attached code snippet in console App and getting expected output in console.

Screencast: http://www.screencast.com/t/PkSCwtf011
Environment Info: https://gist.github.com/Arpit360/2fd3b86736341972ac56

Note You need to log in before you can comment on or make changes to this bug.