Skip to content

Commit

Permalink
Implement safeguards to prevent exceptions during case-insensitive di…
Browse files Browse the repository at this point in the history
…ctionary generation.
  • Loading branch information
xin9le committed Dec 25, 2024
1 parent a6e76f7 commit 9afc797
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libs/FastEnum.Core/Internals/EnumInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ static EnumInfo()
.DistinctBy(static x => x.Value)
.ToArray();
s_memberByNameCaseSensitive = s_members.ToCaseSensitiveStringDictionary(static x => x.Name);
s_memberByNameCaseInsensitive = s_members.ToCaseInsensitiveStringDictionary(static x => x.Name);
s_memberByNameCaseInsensitive
= s_members
.DistinctBy(static x => x.Name, StringComparer.OrdinalIgnoreCase)
.ToCaseInsensitiveStringDictionary(static x => x.Name);
s_memberByValue = s_orderedMembers.ToFastReadOnlyDictionary(static x => x.Value);
s_minValue = s_values.DefaultIfEmpty().Min();
s_maxValue = s_values.DefaultIfEmpty().Max();
Expand Down

0 comments on commit 9afc797

Please sign in to comment.