Are you open to a PR for a nullable `Name`?
- Dominant language
- C#
- Stars
- 2.4k
- Forks
- 184
- PR merge metrics
- No merged PRs in 30d
Description
hey steve, wanted to check if you were open to a PR that would allow for a null name? this could be useful when you want a smart enum to capture a response like `not given` without jumping through extra hoops externally or adding an empty string in the smart enum. for example:
```csharp
public abstract class KnownRace(string name, int value) : SmartEnum(name, value)
{
public static readonly KnownRace White = new WhiteType();
public static readonly KnownRace BlackOrAfricanAmerican = new BlackOrAfricanAmericanType();
public static readonly KnownRace NotGiven = new NotGivenType();
public abstract Guid? LegacyGuid { get; }
private const string legacyOtherGuid = "f5b897e4-cdb7-471b-a6d0-f73d399538b2";
private class WhiteType() : KnownRace("White", 0)
{
public override Guid? LegacyGuid => Guid.Parse("113c8858-d971-4335-909d-48e6808d8839");
}
private class BlackOrAfricanAmericanType() : KnownRace("Black or African American", 1)
{
public override Guid? LegacyGuid => Guid.Parse("ffbb2f4c-9667-40df-bac4-14ab568023a4");
}
//....
private class NotGivenType() : KnownRace(" ", 100)
{
public override Guid? LegacyGuid => null;
}
}
```
Contributor guide
Research direction
Start by reviewing the SmartEnum constructor and Name handling implicated by the example, then examine the repository's existing validation and tests for names. Done means the project has an agreed design for nullable names, documented behavior for the "not given" case, and tests covering the resulting API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100