title: Windows Runtime methods cannot be generic - Reasons, Workarounds, Alternatives?
body: <p>Here is an Interface, taken from my attempt to port <a href="https://github.com/flq/MemBus" rel="noreferrer">MemBus</a>, an Event Aggregator I maintain, to the Windows runtime world:</p>
  
  <pre><code>public interface ISubscriber
  {
      IDisposable Subscribe&lt;M&gt;(Action&lt;M&gt; subscription);
  
      #if WINRT 
      [Windows.Foundation.Metadata.DefaultOverload]
      #endif
      IDisposable Subscribe(object subscriber);
  
      IObservable&lt;M&gt; Observe&lt;M&gt;();
  }
  </code></pre>
  
  <p>What I am getting is a Compiler error:</p>
  
  <blockquote>
    <p>"error WME1031: '<code>MemBus.ISubscriber.Subscribe&lt;M&gt;(System.Action&lt;M&gt;)</code>' is a generic method.  Windows Runtime methods cannot be generic."</p>
  </blockquote>
  
  <p>I have only suspicions as to why this is the case, if anybody can clarify, please do. </p>
  
  <p>My main question is: <strong>How are we supposed to deal with this when porting code to the Windows runtime</strong>? </p>
  
  <p>A lot of higher Level functionality happens with generics. In fact, we use generic classes in the Windows Runtime (e.g. <code>List&lt;T&gt;</code>). 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?</p>