Skip to content

Revert PR 412 and remove support for null values. #512

@fiseni

Description

@fiseni

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) { }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions