title: Why is FxCop raising the error "Types that own disposable fields should be disposable" on a class with no disposable fields?
body: <p>I have a LINQ object with an additional method added to it.  The class has no disposable properties or methods, but FxCop is raising the error "Types that own disposable fields should be disposable" and referencing that class.</p>
  
  <p>I've reduced the code this far and still receive the error:</p>
  
  <pre><code>partial class WikiPage
  {
      public PagePermissionSet GetUserPermissions(Guid? userId) {
          using (WikiTomeDataContext context = new WikiTomeDataContext()) {
              var permissions =
                  from wiki in context.Wikis
                  from pageTag in context.VirtualWikiPageTags
                  select new {};
  
              return null;
          }
      }
  }
  </code></pre>
  
  <p>However, if I remove EITHER of the from clauses, FxCop stops giving the error:</p>
  
  <pre><code>partial class WikiPage
  {
      public PagePermissionSet GetUserPermissions(Guid? userId) {
          using (WikiTomeDataContext context = new WikiTomeDataContext()) {
              var permissions =
                  from pageTag in context.VirtualWikiPageTags
                  select new {};
  
              return null;
          }
      }
  }
  </code></pre>
  
  <p>Or</p>
  
  <pre><code>partial class WikiPage
  {
      public PagePermissionSet GetUserPermissions(Guid? userId) {
          using (WikiTomeDataContext context = new WikiTomeDataContext()) {
              var permissions =
                  from wiki in context.Wikis
                  select new {};
  
              return null;
          }
      }
  }
  </code></pre>
  
  <p>PagePermissionSet is not disposable.</p>
  
  <p>Is this a false positive?  Or is the LINQ code somehow generating a disposable field on the class?  If it isn't a false positive, FxCop is recommending that I implement the IDisposable interface, but what would I do in the Dispose method?</p>
  
  <p>EDIT:
  The full FxCop error is:</p>
  
  <blockquote>
    <p>"Implement IDisposable on 'WikiPage' because it 
    creates members of the following IDisposable types: 
    'WikiTomeDataContext'. If 'WikiPage' has previously 
    shipped, adding new members that implement IDisposable 
    to this type is considered a breaking change to existing 
    consumers."</p>
  </blockquote>
  
  <p>Edit 2:
  This is the disassembled code that raises the error:</p>
  
  <pre><code>public PagePermissionSet GetUserPermissions(Guid? userId)
  {
      using (WikiTomeDataContext context = new WikiTomeDataContext())
      {
          ParameterExpression CS$0$0001;
          ParameterExpression CS$0$0003;
          var permissions = context.Wikis.SelectMany(Expression.Lambda&lt;Func&lt;Wiki, IEnumerable&lt;VirtualWikiPageTag&gt;&gt;&gt;(Expression.Property(Expression.Constant(context), (MethodInfo) methodof(WikiTomeDataContext.get_VirtualWikiPageTags)), new ParameterExpression[] { CS$0$0001 = Expression.Parameter(typeof(Wiki), "wiki") }), Expression.Lambda(Expression.New((ConstructorInfo) methodof(&lt;&gt;f__AnonymousType8..ctor), new Expression[0], new MethodInfo[0]), new ParameterExpression[] { CS$0$0001 = Expression.Parameter(typeof(Wiki), "wiki"), CS$0$0003 = Expression.Parameter(typeof(VirtualWikiPageTag), "pageTag") }));
          return null;
      }
  }
  </code></pre>
  
  <p>Edit 3:
  There does appear to be a closure class containing a reference to the DataContext.  Here is its disassembled code:</p>
  
  <pre><code>[CompilerGenerated]
  private sealed class &lt;&gt;c__DisplayClass1
  {
      // Fields
      public WikiTomeDataContext context;
  
      // Methods
      public &lt;&gt;c__DisplayClass1();
  }
  </code></pre>