ardalis / ardalis/SmartEnum

How about a HasFlag() extension method just like a regular enum?

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

Description

I know that @AFM-Horizon is already working (#64) on a SmartFlagsEnum concept for this but I couldn't add an issue on his fork.

HasFlag() is one of the most useful extensions on good old enums. I suppose it wouldn't take much to add that in, given the well-laid out structure of SmartFlagsEnum by @AFM-Horizon.

I would go so far as to have AddFlag() and RemoveFlag() extension methods too, which I have so desperately wished regular enums had. I end-up writing my own AddFlag() and RemoveFlag() methods for most projects where I use enums.

Any thoughts?

Contributor guide

Open the contributing guide

Research direction

Start by reading issue #64 and the referenced SmartFlagsEnum design; this issue names no repository files or tests. Clarify the intended semantics and API for HasFlag(), AddFlag(), and RemoveFlag() with maintainers before implementation; done requires an agreed design and corresponding behavior coverage.

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
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.