Generated Members¶
The source generator emits the following members into a second partial class declaration for each qualifying type.
Static Properties¶
All¶
All members in declaration order. Backed by a statically-initialized array.
Names¶
All member names in declaration order.
Values¶
All member values in declaration order.
Count¶
The number of members. A compile-time constant — replaced with the literal value by the JIT.
Factory Methods¶
FromName¶
Returns the member with the given name. Uses StringComparer.Ordinal (case-sensitive).
Throws: InvalidOperationException if no member has that name.
TryFromName¶
Returns true and sets result if found. Returns false and sets result = null if not found. Never throws.
FromValue¶
Returns the member with the given value.
Throws: InvalidOperationException if no member has that value.
TryFromValue¶
Returns true and sets result if found. Returns false and sets result = null if not found. Never throws.
Membership Methods¶
ContainsName¶
Returns true if a member with that name exists. Equivalent to TryFromName(name, out _) but marginally faster (no out parameter overhead).
ContainsValue¶
Returns true if a member with that value exists.
Implementation Notes¶
All lookup methods are backed by pre-built Dictionary<K, TEnum> instances:
s_byName—Dictionary<string, TEnum>withStringComparer.Ordinals_byValue—Dictionary<TValue, TEnum>with default comparer
Both are static readonly fields initialized at type-load time. Lookups are O(1).