fix: Smarter Enum Conversion#1109
Merged
paulhazen merged 4 commits intorelease-3.3.6from Jan 31, 2025
Merged
Conversation
Contributor
|
Retargeted to |
WispyMouse
reviewed
Jan 29, 2025
Contributor
WispyMouse
left a comment
There was a problem hiding this comment.
I ran the ListOfStringsToEnumConverterTests set, which seem relevant here.
ListOfStringsToEnumConverterTestClass_ReadJson_InvalidTokenType_ThrowsException no longer throws an exception, instead setting the value to 0. Should we remove the test?
…um_EvaluatesToZero` Test Adds a test that ensures Flags can have their value set to 0, even if the Enum does not contain 0 as an explicit value.
WispyMouse
approved these changes
Jan 29, 2025
Contributor
WispyMouse
left a comment
There was a problem hiding this comment.
Added test for Flags being set to 0. This looks good to me and functions correctly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves the way in which a number value is cast into an
enumtype viaEnumUtility.Currently, when an attempt is made to convert a value that does not correspond to a named value within the
enum, the lowest value in theenumis selected.This change checks not just for if the value is out of range by being too low, but also checking for if the value is out of range by being too high. If either is the case, then instead of selecting the highest or lowest value accordingly, a value of 0 is selected.
Despite not necessarily being a named value within an
enum,0is always a valid value for anyenum, and is used to indicate a value that is not set.#EOS-2381