Here is an Interface, taken from my attempt to port MemBus, an Event Aggregator I maintain, to the Windows runtime world:
public interface ISubscriber
{
IDisposable Subscribe<M>(Action<M> subscription);
#if WINRT
[Windows.Foundation.Metadata.DefaultOverload]
#endif
IDisposable Subscribe(object subscriber);
IObservable<M> Observe<M>();
}
What I am getting is a Compiler error:
"error WME1031: '
MemBus.ISubscriber.Subscribe<M>(System.Action<M>)
' is a generic method. Windows Runtime methods cannot be generic."
I have only suspicions as to why this is the case, if anybody can clarify, please do.
My main question is: How are we supposed to deal with this when porting code to the Windows runtime?
A lot of higher Level functionality happens with generics. In fact, we use generic classes in the Windows Runtime (e.g. List<T>
). How is a RT component supposed to expose generic types, and if not, is the only alternative available to go back to the ways of writing .NET 1.1 code, i.e. object in, object out and do casts?