mirror of
https://github.com/icsharpcode/ILSpy.git
synced 2026-10-12 02:15:58 +00:00
Enum members whose value duplicates an earlier member now reference it (Item2B = Item2A), [Flags] members combine earlier single-bit members (All = Item1 | Item2 | Item3) or their complement (NotItem1 = ~Item1) instead of showing a bare number. Several guardrails keep the output faithful to how such enums are written by hand: only previously declared members are referenced (field row order); a multi-bit value lying entirely within a larger, earlier member is a field encoding inside that mask, not a flag union, and stays numeric, as do zero-valued members of [Flags] enums, which routinely have several unrelated zero members. The ~X form is suppressed in byte/ushort enum declarations, where the initializer constant folds in int and would not compile. Enums with unusual underlying types (bool, native int) keep the plain constant conversion. With these rules, decompiling System.Private.CoreLib reproduces the hand-written declarations of TypeAttributes, MethodAttributes, AttributeTargets and FileAttributes almost verbatim. Assisted-by: Claude:claude-fable-5:Claude Code