Open
Description
Given a enum class as follow:
[AllowUnsafeFlagEnumValues]
public sealed class FooEnum : SmartFlagEnum<FooEnum, uint> {
public static readonly FooEnum Flag32 = new(nameof(Flag32), 0x01u << 31);
public static readonly FooEnum Flag1 = new(nameof(Flag1), 0x01u << 0);
FooEnum(string name, uint value) : base(name, value) { }
}
The following code
FooEnum.FromValue(0b_0000_0001u)
throws exception:
Unhandled exception. System.OverflowException: Value was either too large or too small for an Int32.
at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, ReadOnlySpan`1 value, TypeCode type)
at System.Int32.Parse(String s)
at Ardalis.SmartEnum.SmartFlagEngine`2.HighestFlagValue(IReadOnlyList`1 enumList)
at Ardalis.SmartEnum.SmartFlagEngine`2.CalculateHighestAllowedFlagValue(List`1 inputEnumList)
at Ardalis.SmartEnum.SmartFlagEngine`2.GetFlagEnumValues(TValue value, IEnumerable`1 allEnumList)
at Ardalis.SmartEnum.SmartFlagEnum`2.FromValue(TValue value)
Metadata
Metadata
Assignees
Labels
No labels