title: Why does VS warn me that typeof(T) is never the provided type in a generic method where the type parameter is restricted to implement T?
body: <p>I hope the question is correct, so let's give you an example. Imagine the following generic method:</p>
  
  <pre><code>public abstract class Base : IDisposable
  {
      public static IEnumerable&lt;T&gt; GetList&lt;T&gt;()
          where T : Base
      {
          // To ensure T inherits from Base.
          if (typeof(T) is Base)
              throw new NotSupportedException();
  
          // ...
      }
  }
  </code></pre>
  
  <p>According to the <a href="http://msdn.microsoft.com/de-DE/library/bb384067.aspx" rel="noreferrer">MSDN</a> the keyword <code>where</code> restricts the type parameter <code>T</code> to be of type <code>Base</code> or to inherit from this class.</p>
  
  <blockquote>
    <p>[...] a where clause can include a base class constraint, which states that a type must have the specified class as a base class (or be that class itself) in order to be used as a type argument for that generic type.</p>
  </blockquote>
  
  <p>Also this code does compile:</p>
  
  <pre><code>public static T GetFirst()
      where T : Base
  {
      // Call GetList explicitly using Base as type parameter.
      return (T)GetList&lt;Base&gt;().First();
  }
  </code></pre>
  
  <p>So when following the last code <code>typeof(T)</code> should return <code>Base</code>, shouldn't it? Why does Visual Studio then prints this warning to me?</p>
  
  <blockquote>
    <p>warning CS0184: The given expression is never of the provided ('Demo.Base') type.</p>
  </blockquote>