Skip to content

Add SupportsReading plumbing#5472

Merged
NinoFloris merged 2 commits intomainfrom
fix-reading-assignablefrom-mappings
Nov 3, 2025
Merged

Add SupportsReading plumbing#5472
NinoFloris merged 2 commits intomainfrom
fix-reading-assignablefrom-mappings

Conversation

@NinoFloris
Copy link
Member

@NinoFloris NinoFloris commented Dec 4, 2023

See test for what used to resolve succesfully.

Originally StreamByteaConverter would throw NotSupported during reading. Had it implemented the read methods though (i.e. via reader.GetStream()) as is done in #5480 we would start to throw at the GetFieldValueCore level trying to cast the return value from ReadAsObject (runtime type ColumnStream) to the requested NetworkStream.

In the case of IPAddressConverter we would throw inside the casting converter on read, trying to cast an IPAddress instance to whatever derived type was requested.

Better to head these cases off just after finding an info via a new read side analog of SupportsWriting.

@NinoFloris NinoFloris force-pushed the fix-reading-assignablefrom-mappings branch from a19e003 to a393f4a Compare December 4, 2023 18:59
@NinoFloris NinoFloris added this to the 9.0.0 milestone Dec 4, 2023
@NinoFloris NinoFloris closed this Mar 27, 2024
@NinoFloris NinoFloris reopened this Mar 27, 2024
@vonzshik vonzshik modified the milestones: 9.0.0, 10.0.0 Oct 21, 2024
@roji roji removed the enhancement label Jun 14, 2025
@NinoFloris NinoFloris force-pushed the fix-reading-assignablefrom-mappings branch from 9bceeaf to 192bab0 Compare October 30, 2025 00:43
static (options, mapping, _) => new PgTypeInfo(options, new IPAddressConverter(),
new DataTypeName(mapping.DataTypeName), unboxedType: mapping.Type == typeof(IPAddress) ? null : mapping.Type),
static (options, mapping, _) => new PgTypeInfo(options, new IPAddressConverter(), new DataTypeName(mapping.DataTypeName),
unboxedType: mapping.Type != typeof(IPAddress) ? mapping.Type : null),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super minor nit: FWIW I prefer the the previous ternary to avoid double negation

@NinoFloris NinoFloris merged commit c3e2fc2 into main Nov 3, 2025
16 checks passed
@NinoFloris NinoFloris deleted the fix-reading-assignablefrom-mappings branch November 3, 2025 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants