In one of my projects, I have code similar to the following:
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; }
When I run FxCop in this code, I get warning CA1049 . This structure is used to interact with its own code library, so it has this layout to a large extent. Why does FxCop give me sadness about this structure? I have other structures in the same source file that also have IntPtr members, but FxCop does not complain about them.
For example, the following code does not cause the same warning:
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; }
I suppose I could implement IDisposable in a structure, but that just seems to be wrong. Likewise, I could just suppress this warning, but for now I want to understand what this particular structure is that causes a warning when it is not very different from the other seven structures that I have in one source file. Alternatively, I would gladly accept the explanation why other entities do not trigger this warning.