After reading through the Windows 8 app certification requirements, I was wondering why they state this:
•Must apply the FlagsAttribute to UInt32 enums.
•Must not apply the FlagsAttribute to Int32 enums.
What’s the reasoning behind it?
The certification requirements can currently be found at http://msdn.microsoft.com/en-us/library/windows/apps/hh694083.aspx
There are two scenarios for the use of Enums in WinRT: As enumerated value constants and as bitfield value constants. The enumerated value form is represented as a signed integer (because it is enumerated) and the bitfield form is represented as an unsigned integer (to allow all 32 bits to be used for flags). All bitfield enums are required to have the FlagsAttribute.
This rule in the validation logic enforces that the underlying type of the enum is correct given the value of the FlagsAttribute.
This is important because some of the language projections will not correctly consume enums with the FlagsAttribute if the underlying type of the enum is signed.