Fix/prefer typehandlers for enums#2200
Open
andreasblueher wants to merge 2 commits intoDapperLib:mainfrom
Open
Fix/prefer typehandlers for enums#2200andreasblueher wants to merge 2 commits intoDapperLib:mainfrom
andreasblueher wants to merge 2 commits intoDapperLib:mainfrom
Conversation
When enabled, Dapper checks for a registered TypeHandler for enum types before falling back to the default integer boxing behavior. This allows custom enum serialization (e.g. storing enums as strings via TypeHandlers) to work on both reads and writes. Patched locations: - LookupDbType: return DbType.Object with handler when flag is on - CreateParamInfoGenerator: skip integer boxing when handler exists - GetSimpleValueDeserializer: route to TypeHandler before Enum.ToObject - Parse<T>: route to TypeHandler before Enum.ToObject Default is false — zero behavior change for existing users.
- Fix 6th enum-before-handler location in GetTypeDeserializer IL emit, preserving Nullable<T> wrapping for nullable enum properties - Fix em-dash in comment (non-ASCII) - Add two tests: round-trip write+read via StringEnumHandler, and nullable enum with null value
Member
|
Yep, I need to find a chunk of time to chew through a ton of issues and PRs |
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.
Hello @mgravell,
I know there have been already 2 pull requests (#458 & #1711) for the issue #259 which haven't been merged because users might rely on the current way dapper works with enums.
Since I'm using tons of enums, I created a suggestions to introduce a opt-in flag, which allows current users to stay on their behavior and others like me to get an updated version. Since 3.0 seems far, maybe this is something you could consider merging.
Best regards,
Andreas