Skip to content

Handle undefined and combined flag values in AbpEnumLocalizer - #26344

Open
johnkaram02 wants to merge 2 commits into
abpframework:rel-10.7from
johnkaram02:fix/enum-localizer-undefined-value
Open

johnkaram02 wants to merge 2 commits into
abpframework:rel-10.7from
johnkaram02:fix/enum-localizer-undefined-value

Conversation

@johnkaram02

@johnkaram02 johnkaram02 commented Oct 28, 2026 •

Copy link
Copy Markdown

AbpEnumLocalizer and the obsolete EnumHelper threw ArgumentNullException for values without a named member, such as (BookType)42 or a combined [Flags] value. They now fall back to the enum's ToString() result ("42", "Read, Write"). Named members behave as before.

@CLAassistant

CLAassistant commented Oct 28, 2026 •

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ maliming
❌ johnkaram02
You have signed the CLA already but the status is still pending? Let us recheck it.

johnkaram02 and others added 2 commits October 28, 2026 13:29
AbpEnumLocalizer used Type.GetEnumName as the member name. GetEnumName
returns null for a value that has no named member, such as (BookType)42
or a combination of [Flags] members. The null key then reached the
string localizer and GetString threw an ArgumentNullException.

Fall back to the enum's ToString() result, such as "42" or "Read, Write",
when the value has no named member.
@maliming
maliming force-pushed the fix/enum-localizer-undefined-value branch from 377e2b5 to ce06e78 Compare October 28, 2026 05:40
@maliming
maliming changed the base branch from dev to rel-10.7 October 28, 2026 05:41
@maliming

Copy link
Copy Markdown
Member

Thanks for the PR.

Bug fixes go to the release branch first and are merged into dev automatically, so I moved your commit onto rel-10.7 and changed the base branch. I also added tests for an integer flags value and a specified localizer, and applied the same fallback to the obsolete EnumHelper.

Please complete the CLA check, then we can merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants