title: Tell FxCop another method is calling dispose
body: <p>Typically when you dispose a private member, you might do the following:</p>
  
  <pre><code>public void Dispose() {
      var localInst = this.privateMember;
      if (localInst != null) {
          localInst.Dispose();
      }
  }
  </code></pre>
  
  <p>The purpose of the local assignment is to avoid a race condition where another thread might assign the private member to be null after the null check. In this case, I don't care if <code>Dispose</code> is called twice on the instance.</p>
  
  <p>I use this pattern all the time so I wrote an extension method to do this:</p>
  
  <pre><code>public static void SafeDispose(this IDisposable disposable)
  {
      if (disposable != null)
      {
          // We also know disposable cannot be null here, 
          // even if the original reference is null.
          disposable.Dispose();
      }
  }
  </code></pre>
  
  <p>And now in my class, I can just do this:</p>
  
  <pre><code>public void Dispose() {
      this.privateMember.SafeDispose();
  }
  </code></pre>
  
  <p>Problem is, FxCop has no idea I'm doing this and it gives me the <a href="http://msdn.microsoft.com/en-us/library/ms182289.aspx" rel="nofollow noreferrer">CA2000: Dispose objects before losing scope</a> warning in every case.</p>
  
  <p>I don't want to turn off this rule and I don't want to suppress every case. Is there a way to hint to FxCop that this method is equivalent to <code>Dispose</code> as far as it's concerned?</p>