icsharpcode/ILSpy — Issue #304: Search for enum underlying type is incorrect
Author: 0xd4d
Created: 2011-12-30 07:02:21+00:00
State: open

According to the spec (Partition I, page 32)

An enum is considerably more restricted than a true type, as follows:
· It shall have exactly one instance field, and the type of that field defines the underlying type of the enumeration.

However, the code searches for the underlying type by checking the RTSpecialName bit.

At least these files need to be updated:

AstBuilder.cs : CreateType(TypeDefinition), MakePrimitive(long,TypeReference)
TypeAnalysis.cs : A few typeDef.Fields.Single() calls

A simple field.IsStatic test is all that is needed.