ardalis / ardalis/SmartEnum

Add support for NRT

Open
#511 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2.4k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

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 to `struct`.

```csharp
public abstract class SmartEnum :
ISmartEnum,
IEquatable>,
IComparable>
where TEnum : SmartEnum
where TValue : struct, IEquatable, IComparable
```
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.

Contributor guide

Open the contributing guide

Research direction

Start at the SmartEnum declaration shown in the issue and inspect how TValue is used throughout the library. Review whether reference-type enum values are supported by existing consumers and assess the impact of constraining TValue to struct. Done means the NRT support and resulting breaking-change scope are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.