title: CodeContracts: Boolean condition evaluates to a constant value, why?
body: <p>I'm getting this warning but can't figure out the problem...</p>
  
  <blockquote>
    <p>CodeContracts: warning: The Boolean condition d1.Count !=
    d2.Count always evaluates to a constant value. If it (or its negation)
    appear in the source code, you may have some dead code or redundant
    check</p>
  </blockquote>
  
  <p>The code is as follows:</p>
  
  <pre><code>public static bool DictionaryEquals&lt;TKey, TValue&gt;(IDictionary&lt;TKey, TValue&gt; d1, IDictionary&lt;TKey, TValue&gt; d2)
  {
      if (d1 == d2) return true;
      if (d1 == null || d2 == null) return false;
      if (d1.Count != d2.Count) return false; // &lt;-- warning here
  
      // Equality check goes here
  
      return true;
  }
  </code></pre>
  
  <p>The <code>// Equality check goes here</code> part can be as is, or replaced by <a href="https://stackoverflow.com/a/3804455/1036728">a proper implementation</a> and I still get the same warning.</p>