Add consistent nullable unwrapping to dynamic resolvers#6548
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes #6547 by ensuring dynamic type resolvers handle Nullable<T> consistently (unwrap to T when generating mappings), preventing failures when array mappings are generated from value-type mappings.
Changes:
- Unwrap
Nullable<T>element types before callingAddArrayMapping(...)across several dynamic array resolvers (enum/tuple/json). - When auto-generating array mappings from an existing mapping set, skip
Nullable<T>entries to avoid invalidNullable<Nullable<T>>generic construction. - Extend similar nullable-unwrapping behavior to unmapped range/multirange array resolvers and align nullable checks/guards in
DynamicTypeInfoResolver.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Npgsql/Internal/ResolverFactories/UnmappedTypeInfoResolverFactory.cs | Unwraps nullable element types when generating range/multirange array mappings (including default-mapping fallback path). |
| src/Npgsql/Internal/ResolverFactories/TupledRecordTypeInfoResolverFactory.cs | Adds nullable-aware matching for tuple record mappings and unwraps nullable element types for array mapping generation. |
| src/Npgsql/Internal/ResolverFactories/JsonDynamicTypeInfoResolverFactory.cs | Unwraps nullable types when dynamically mapping json/jsonb and avoids generating array mappings for Nullable<T> base mappings. |
| src/Npgsql/Internal/DynamicTypeInfoResolver.cs | Refactors mapping methods to consistently reject explicit nullable mappings for value types while keeping value/reference paths clearer. |
| src/Npgsql.Json.NET/Internal/JsonNetPocoTypeInfoResolverFactory.cs | Mirrors the json/jsonb nullable-handling fixes for the Json.NET plugin resolver (skip nullable base mappings + unwrap element types). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
(cherry picked from commit 715baa7)
(cherry picked from commit 715baa7)
|
Hi @NinoFloris, thank you for the fix! |
|
They have just been backported for future release. We generally accumulate many other small fixes in these branches until we release new patch versions to nuget. If you really need the fix today you can consider referencing our myget package (https://www.myget.org/feed/npgsql/package/nuget/Npgsql) for the most recent 10.0.3 branch instead. |
Closes #6547
This should be backported until 8.x as well.