This answer is to elborate my thoughts on this interesting problem. Not a real answer, but a contribution to the whole discussion that is too small for a normal comment.
I checked a few things, this interface:
namespace DifferentAssemblyNamespace
{
public interface IBar
{
event Action<dynamic> OnSomeEvent;
}
}
and its implementation:
// implicit interface implementation
// generates compile error "Explicit interface implementation"
public class Foo1 : IBar
{
private Action<dynamic> foo;
public event Action<dynamic> OnSomeEvent
{
add { foo += value; }
remove { foo -= value; }
}
}
// implicit interface implementation
// generates compile error "Not supported by the language"
public class Foo2 : IBar
{
private Action<dynamic> foo;
event Action<dynamic> IBar.OnSomeEvent
{
add { foo += value; }
remove { foo -= value; }
}
}
will never work, seems that one rule is excluding the other necessary rule.
but.. if we call generics for help, and use a Type parameter instead of using dynamic
directly like:
namespace DifferentAssemblyNamespace
{
public interface IGenericBar<T>
{
event Action<T> OnSomeEvent;
}
}
and its implementation.
// implicit interface implementation
public class Foo3<T> : IGenericBar<T>
{
private Action<T> foo;
event Action<T> IGenericBar<T>.OnSomeEvent
{
add { foo += value; }
remove { foo -= value; }
}
}
for some reason we can build (as it should) and run:
/** does build **/
IGenericBar<dynamic> f = new Foo3<dynamic>();
f.OnSomeEvent += new Action<dynamic>(f_OnSomeEvent);
seems that the Type Parameter does something extra that the compiler is happy with.
I am not sure what is going on, so I would like to know as well.
assumption, highly hypothetical (perhaps crap)
but currently I put my two cents on
the comparison of types there must be
made via the add/remove accessors in
the linked list that holds the
target/methods of the event.
I bet
that the compiler falls over the
problem that it cannot guarantee what
dynamic is in the external assembly, thus cannot determine if an element is already in the list or not, which is necessary to add or remove them.(Hence explicit interface implementation)
We all know it is just some of a
attributed object but it still seems
that it needs an extra step where some
strong-type is guaranteed, and that is
what T does, at compile time.
/ assumption, highly hypothetical (perhaps crap)