The premise of this library is that it can extend the built-in enum types in .NET, but still, it will mimic the behavior of the enum types. SmartEnums even though defined as classes, they're extended to offer value-type behavior.
This PR enables creating a SmartEnum with a null value. This breaks the assumed contract and leads to various inconsistencies. For instance, we can no longer guarantee that SmartEnum can be used as dictionary keys.
var types = new Dictionary<CustomerType, object>();
types.Add(CustomerType.One, new()); // Will throw
public class CustomerType : SmartEnum<CustomerType, string>
{
public static CustomerType One = new CustomerType("One", null);
public static CustomerType Two = new CustomerType("Two", "two");
protected CustomerType(string name, string value) : base(name, value) { }
}
The premise of this library is that it can extend the built-in enum types in .NET, but still, it will mimic the behavior of the enum types. SmartEnums even though defined as classes, they're extended to offer value-type behavior.
This PR enables creating a SmartEnum with a null value. This breaks the assumed contract and leads to various inconsistencies. For instance, we can no longer guarantee that SmartEnum can be used as dictionary keys.