Revert PR 412 and remove support for null values.
- Dominant language
- C#
- Stars
- 2.4k
- Forks
- 184
- PR merge metrics
- No merged PRs in 30d
Description
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](https://github.com/ardalis/SmartEnum/pull/412) 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.
```csharp
var types = new Dictionary();
types.Add(CustomerType.One, new()); // Will throw
public class CustomerType : SmartEnum
{
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) { }
}
```
Contributor guide
Research direction
Start by reviewing PR 412 and the SmartEnum value-handling entry points it changed. Restore the non-null value contract described in the issue and verify that a SmartEnum with a null value cannot be created and can safely be used as a dictionary key.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100