ardalis / ardalis/SmartEnum

Methods FromName() and TryFromName() for SmartFlagEnum do not work with ignore case at true

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

Description

With the example of EmployeeType in documentation, when using .FromName (ou .TryFromName) with the ignore case flag, no value is returned.

`IEnumerable types = EmployeeType.FromName("director, manager", true);`

The issue is due to the method TryGetFlagEnumValuesByName in SmartFlagEnumExtensions: The BinarySearch on the array should use a System.Collections.CaseInsensitiveComparer as third parameter in this scenario.

Contributor guide

Open the contributing guide

Research direction

Start with TryGetFlagEnumValuesByName in SmartFlagEnumExtensions and reproduce the EmployeeType.FromName("director, manager", true) example from the documentation. Check the case-insensitive lookup path and verify that both FromName and TryFromName return the expected values when ignore case is true.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
backend-api-design
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.