ardalis / ardalis/SmartEnum

Can/should SmartEnum implement the non-generic IComparable interface?

Open
#427 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted
Dominant language
C#
Stars
2.4k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

Hi. We depend on some framework code that does comparison of objects based on the non-generic IComparable interface. I just stumbled across a CS0029 compilation error when trying to use a SmartEnum derived type. I quickly realized that this is because it doesn't implement the non-generic version of the IComparable interface, only the generic one.

In this particular case, I can modify my SmartEnum-derived type to implement IComparable itself, but that may not always be possible, and obviously isn't desirable from a DRY/code maintenance point of view.

Is there a reason that SmartEnum couldn't or shouldn't also implement the non-generic IComparable interface?

Thanks in advance for any consideration of this idea.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the SmartEnum base class and its existing generic IComparable implementation, then check how the reported framework comparison scenario is expected to work. Done means reaching a documented decision on non-generic IComparable support, with compatible behavior covered by the project's tests if the change is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
developer-experience
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.