title: Resharper: Possible null assignment to entity marked with "NotNull" attribute
body: <p>I apologize if this question is a bit obsessive but I do like my code not to have any wiggly lines underneath it where resharper is telling me off.</p>
  
  <p>I have a generic list:</p>
  
  <pre><code>var permissions = new List&lt;Permission&gt;();
  </code></pre>
  
  <p>at some point in the code I need to test the first element:</p>
  
  <pre><code>if (permissions.First().ImportID == this.ImportId)
  {
     // do stuff
  }
  </code></pre>
  
  <p>Resharper (rightly) complains that permissions could be null,  so I take its advice and add a check in:</p>
  
  <pre><code>if (permissions != null &amp;&amp; permissions.First().ImportID == this.ImportId)
  {
     // do stuff
  }
  </code></pre>
  
  <p>Now I realise that I need to protect against the list being empty so I add a check for any in there too:</p>
  
  <pre><code>if (permissions != null &amp;&amp; permissions.Any() &amp;&amp; permissions.First().ImportID == this.ImportId)
  {
      // do stuff
  }
  </code></pre>
  
  <p>and life is good, the code works &amp; resharper is quiet.  Realising that the null + any() check is going to be used quite often I add an extension method:</p>
  
  <pre><code>public static bool IsEmpty&lt;T&gt;(this IEnumerable&lt;T&gt; source)
  {
      if (source == null)
          return true; 
      return !source.Any();
  }
  </code></pre>
  
  <p>The only problem is now when I use this:</p>
  
  <pre><code>if (!permissions.IsEmpty() &amp;&amp; permissions.First().ImportID == this.ImportId)
  </code></pre>
  
  <p>Resharper starts moaning again "Possible null assignment to entity marked with "NotNull" attribute".  </p>
  
  <p>So, is there a way to let resharper know that permissions will never be null after IsEmpty() has executed (in the same way it understands what != null does)  or is my only option to ignore the message.</p>