It would be nice to enable the NRT in the library. It will offer a better experience for the consumers and fix some subtle issues.
But. I don't think we'll be able to do that with the current structure (at least I couldn't). I'd suggest constraining the TValue generic parameter to struct.
public abstract class SmartEnum<TEnum, TValue> :
ISmartEnum,
IEquatable<SmartEnum<TEnum, TValue>>,
IComparable<SmartEnum<TEnum, TValue>>
where TEnum : SmartEnum<TEnum, TValue>
where TValue : struct, IEquatable<TValue>, IComparable<TValue>
Conceptually, that makes sense. But, it would require some substantial refactoring and will be a major breaking change. I'm not sure if anyone is using reference types as enum values, but there are such users probably.
Ok, I see a lot of consumers are using string as the enum value. It's even provided as a sample in docs here. So, constraining to struct won't be a good idea. I'll give it another try enabling the NRT in the current form.
Hi,
It would be nice to enable the NRT in the library. It will offer a better experience for the consumers and fix some subtle issues. But. I don't think we'll be able to do that with the current structure (at least I couldn't). I'd suggest constraining the
TValue
generic parameter tostruct
.Conceptually, that makes sense. But, it would require some substantial refactoring and will be a major breaking change. I'm not sure if anyone is using reference types as enum values, but there are such users probably.