You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2a8faab
Browse filesBrowse the repository at this point in the historyBrowse files
* Add Settings.PreferTypeHandlersForEnums opt-in flag
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.
* Patch IL-emitted type deserializer and add tests
- 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
* Update SDK version from 10.0.102 to 8.0.100
* Update global.json
we have fixed the CI glitch separately
---------
Co-authored-by: Marc Gravell <marc.gravell@gmail.com>
il.Emit(OpCodes.Castclass,typeof(string));// stack is now [...][string]
3750
-
il.Emit(OpCodes.Stloc,stringEnumLocal);// stack is now [...]
3751
-
il.Emit(OpCodes.Ldtoken,unboxType);// stack is now [...][enum-type-token]
3752
-
il.EmitCall(OpCodes.Call,typeof(Type).GetMethod(nameof(Type.GetTypeFromHandle))!,null);// stack is now [...][enum-type]
3753
-
il.Emit(OpCodes.Ldloc,stringEnumLocal);// stack is now [...][enum-type][string]
3754
-
il.Emit(OpCodes.Ldc_I4_1);// stack is now [...][enum-type][string][true]
3755
-
il.EmitCall(OpCodes.Call,enumParse,null);// stack is now [...][enum-as-object]
3756
-
il.Emit(OpCodes.Unbox_Any,unboxType);// stack is now [...][typed-value]
3769
+
#pragma warning disable 618
3770
+
il.EmitCall(OpCodes.Call,typeof(TypeHandlerCache<>).MakeGenericType(unboxType).GetMethod(nameof(TypeHandlerCache<int>.Parse))!,null);// stack is now [...][typed-value]
0 commit comments