[Mono-bugs] [Bug 385125] Delegates don't compare ==
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Wed Apr 30 23:05:34 EDT 2008
https://bugzilla.novell.com/show_bug.cgi?id=385125
User albright at wesay.org added comment
https://bugzilla.novell.com/show_bug.cgi?id=385125#c3
Eric Albright <albright at wesay.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEEDINFO |NEW
Info Provider|albright at wesay.org |
--- Comment #3 from Eric Albright <albright at wesay.org> 2008-04-30 21:05:33 MST ---
I get the same results whether using mcs/gmcs.
Running gmcs/mcs --about gives me 1.9.0.0
I refactored the code into a standalone app, if that helps. I get False for
both
(return 3) compiled under Mono and True for both (return 0) compiled under .Net
using System;
namespace MonoBug
{
sealed public class MyTest
{
sealed private class EventHandlers
{
private EventHandler _handler = DoNothingEventHandler;
public static EventHandler DoNothingEventHandler
{
get
{
return delegate
{
};
}
}
private int i;
public EventHandler DoSomethingEventHandler
{
get
{
return delegate
{
++i;
};
}
}
public EventHandler Handler
{
get
{
return _handler;
}
set
{
_handler = value;
}
}
}
static int Main()
{
EventHandlers handlers = new EventHandlers();
handlers.Handler = handlers.DoSomethingEventHandler;
Console.WriteLine("Is handlers.Handler ==
handlers.DoSomethingEventHandler (instance)?");
Console.WriteLine("Expected: True");
Console.Write ("Actual: ");
bool instanceEqual = handlers.Handler ==
handlers.DoSomethingEventHandler;
Console.WriteLine(instanceEqual);
Console.WriteLine();
handlers.Handler = EventHandlers.DoNothingEventHandler;
Console.WriteLine("Is handlers.Handler ==
EventHandlers.DoNothingEventHandler (static)?");
Console.WriteLine("Expected: True");
Console.Write("Actual: ");
bool staticEqual = handlers.Handler ==
EventHandlers.DoNothingEventHandler;
Console.WriteLine(staticEqual);
if (instanceEqual)
if (staticEqual)
return 0; // instance passed, static passed
else
return 1; // instance passed, static failed
else
if (staticEqual)
return 2; // instance failed, static passed
else
return 3; // instance failed, static failed
}
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list