ardalis / ardalis/SmartEnum

Doesn't seem to have support for Flags Enums

Open
#59 8 comments 3 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
C#
Stars
2.4k
Forks
184
PR merge metrics
No merged PRs in 30d

Description

My team really likes this project and would like to use it for our codebase! Unfortunately, we have several flags enums and they don't seem to be compatible with this project. :(

The `FromValue` method throws a SmartEnumNotFoundException when given a flags enum value as well as casting a flags value.
```
// Given SomeEnum.A is 1 and SomeEnum.B is 2, all three throw the exception
SomeEnum.FromValue(SomeEnum.A | SomeEnum.B);
SomeEnum.FromValue(3);
(SomeEnum)3
```
Also, there's no way to get the Name of multiple values with the logical OR operator like we get when the `Flags` attribute is placed on an enum (i.e. `SomeEnum.B | SomeEnum.C` => `B, C`).

Will this project include this support in the near future?

Contributor guide

Open the contributing guide

Research direction

Start at the FromValue entry point and the SmartEnumNotFoundException path, reproducing the three combined flag-value examples from the issue. Define and verify behavior for logical-OR values and names matching the Flags attribute’s B, C example; done means supported combined values no longer throw and their names are returned as specified.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.