-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider numeric string json for EnumConverter. #79432
Merged
eiriktsarpalis
merged 25 commits into
dotnet:main
from
lateapexearlyspeed:lateapexearlyspeed-ConsiderNumericStringEnum
Oct 6, 2023
Merged
Changes from 6 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
5d95f67
Consider numeric string json for EnumConverter.
lateapexearlyspeed 098204a
Fix comment: just use bit operation rather than HasFlag.
lateapexearlyspeed afeb8e1
Add test.
lateapexearlyspeed 732cb3a
Refine code.
lateapexearlyspeed 58dc738
Merge remote-tracking branch 'origin/main' into lateapexearlyspeed-Co…
lateapexearlyspeed 05555d9
Fix comment: refine comment.
lateapexearlyspeed 180c9bb
Revert EnumConverter change.
lateapexearlyspeed 44029a9
Complete check if current value is numeric string value, and then byp…
lateapexearlyspeed d745c60
Add more tests.
lateapexearlyspeed 5886f87
Fix issue on non-netcoreapp target.
lateapexearlyspeed 1201c89
Merge branch 'main' into lateapexearlyspeed-ConsiderNumericStringEnum
lateapexearlyspeed cca8cc2
Use new CreateStringEnumOptionsForType() in tests.
lateapexearlyspeed 045f851
Merge remote-tracking branch 'upstream/main' into lateapexearlyspeed-…
lateapexearlyspeed ec0024d
Fix comment: move check logic into TryParseEnumCore; turn to use RegEx.
lateapexearlyspeed 1d15cce
use regex generator.
lateapexearlyspeed 92ca867
Add fs test cases about Enum with numeric labels.
lateapexearlyspeed 541f3c5
Update fs test case.
lateapexearlyspeed c214d39
Fix comment: refine test cases in F#.
lateapexearlyspeed 002f5d5
Fix comment: refine test cases in F#.
lateapexearlyspeed cd997df
Fix comment: refine Regex usage.
lateapexearlyspeed f07828b
Update src/libraries/System.Text.Json/src/System/Text/Json/Serializat…
eiriktsarpalis f29e91f
Move Regex to non-generic helper class
eiriktsarpalis 5ceba05
Update src/libraries/System.Text.Json/src/System/Text/Json/Serializat…
eiriktsarpalis ee9efd0
Remove duplicated logic
eiriktsarpalis 357d84c
Remove raw pointer usage.
eiriktsarpalis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This predates your changes, but I'm kind of puzzled as to why we do this. Couldn't this just have been a single parse call with
ignoreCase
set to true?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just guess it was for performance. Considering more common case is
source
is exactly same as Enum name, and case-sensitive comparing ofEnum.TryParse
may be faster than obscure comparing ?Also there is STJ doc sample with same code pattern and the comment said
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, thanks. I'll see if I can validate that claim with a benchmark :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gives
While it's true that the current approach is marginally faster, it drastically regresses performance in case insensitive cases. I think we should just use a single method call. cc @stephentoub