title: Why does FxCop insist on IDisposable for a struct
body: <p>I have the code similar to the following in one of my projects:</p>
  
  <pre><code>internal enum ArtworkType
  {
      Undefined = 0,
      Bmp = 1,
      Gif = 2,
      Jpeg = 3,
      Png = 4
  }
  
  [StructLayout(LayoutKind.Sequential)]
  internal struct TagArtwork
  {
      internal IntPtr data;
      internal int size;
      internal ArtworkType type;
  }
  </code></pre>
  
  <p>When I run FxCop on this code, I get run into warning <a href="http://msdn.microsoft.com/en-us/library/ms182173.aspx" rel="nofollow">CA1049</a>. This struct is used for interoperability with a native code library, so it pretty much <strong>has</strong> to have this layout. Why does FxCop give me grief about this struct? I have other structs in the same source file, which also have <code>IntPtr</code> members, but FxCop does not complain about those.</p>
  
  <p>For example, the following code does <strong>not</strong> trigger the same warning:</p>
  
  <pre><code>internal enum ItemType
  {
      Implicit = 0,
      Utf8 = 1,
      Utf16 = 2,
      Sjis = 3,
      Html = 6,
      Xml = 7,
      Uuid = 8,
      Isrc = 9,
      Mi3p = 10,
      Gif = 12,
      Jpeg = 13,
      Png = 14,
      Url = 15,
      Duration = 16,
      DateTime = 17,
      Genres = 18,
      Integer = 21,
      Riaa_pa = 24,
      Upc = 25,
      Bmp = 27,
      Undefined = 255
  }
  
  [StructLayout(LayoutKind.Sequential)]
  internal struct MP4ItmfData
  {
      internal byte typeSetIdentifier;
      internal ItemType typeCode;
      internal int locale;
      internal IntPtr value;
      internal int valueSize;
  }
  </code></pre>
  
  <p>I suppose I could implement <code>IDisposable</code> on the struct, but that just seems wrong. Likewise, I could simply suppress the warning, but at the moment, I want to understand what it is about this particular struct that is triggering the warning, when it's not that much different than the other seven structs I have in the same source file. Alternatively, I'd happily accept an explanation of why the other structs <strong>don't</strong> trigger this warning.</p>