title: Why do code contracts mark checks on generic type argument as unproven?
body: <p>I defined a following example class having one generic method DoSomething:</p>
  
  <pre><code>public static class MyClass
  {
      public static void DoSomething&lt;T&gt;(T val)
      {
          System.Diagnostics.Contracts.Contract.Requires(typeof(T).IsEnum);
      }
  }
  </code></pre>
  
  <p>And I have the following enum:</p>
  
  <pre><code>public enum MyEnum { A, B }
  </code></pre>
  
  <p>Now I invoke the method with an instance of my enum as follows:</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          MyClass.DoSomething(MyEnum.A);
      }
  }
  </code></pre>
  
  <p>With static checking enabled in the code contracts, the following warning is displayed at the line where I invoke the method:</p>
  
  <blockquote>
    <p>CodeContracts: requires unproven: typeof(T).IsEnum</p>
  </blockquote>
  
  <p>Why is it unproven if it the value is known at compile-time?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Since this is obviously not working, probably because Code Contracts do not understand the semantics of <code>IsEnum</code> or <code>val is Enum</code> (as well pointed out by Jon). I am interested, if there is any known way to do this kind of checks in code contracts?</p>