title: C#, Resharper, "Possible 'null' assignment to entity" warning when it shouldn't be
body: <p>I have a method that turns string.IsNullOrWhiteSpace(string value) into an extension method.</p>
  
  <pre><code>public static bool IsNullOrWhitespace(this string source)
  {
    return string.IsNullOrWhiteSpace(source);
  }
  </code></pre>
  
  <p>After I use this to check for null, Resharper still warns me that the variable  I'm passing as a [NotNull] argument might be null.</p>
  
  <pre><code>"Possible 'null' assignment to entity marked with 'NotNull' attribute"
  </code></pre>
  
  <p>If I replace my use (str.IsNullOrWhiteSpace()) with the original (string.IsNullOrWhiteSpace(str)), the warning doesn't show up. </p>
  
  <p>Is there a way with Resharper that I can train it to know that my extension method is a valid null checker so that this null assignment warning doesn't show up? </p>
  
  <p>Note:</p>
  
  <ol>
  <li>I don't want to hide it with //resharper disable comments everwhere.</li>
  <li>I don't want to disable it entirely, as it should show up when I'm not null-checking.</li>
  </ol>
  
  <p>Edit: </p>
  
  <p>There's a property in the JetBrains.Annotations NuGet package called ContractAnnotation that does the trick.</p>
  
  <pre><code>[ContractAnnotation("source:null =&gt; true")]
  public static bool IsNullOrWhitespace(this string source)
  {
      return string.IsNullOrWhiteSpace(source);
  }
  </code></pre>
  
  <p>This does the trick.</p>