Skip to content

Add built-in support for .NET 6 DateOnly and TimeOnly types#1427

Merged
AArnott merged 3 commits intoMessagePack-CSharp:developfrom
AArnott:fix1240_dateonly
May 24, 2022
Merged

Add built-in support for .NET 6 DateOnly and TimeOnly types#1427
AArnott merged 3 commits intoMessagePack-CSharp:developfrom
AArnott:fix1240_dateonly

Conversation

@AArnott
Copy link
Copy Markdown
Collaborator

@AArnott AArnott commented Apr 26, 2022

DateOnly requires 5 bytes (typically).
TimeOnly requires 6 bytes for second resolution or 8 bytes for ticks resolution. This is automatically selected based on the original value.

Because TimeOnly uses an extension, I claim another extension type code. I venture to add documentation to the README to actually reserve a range of type codes for this and future use, where this previously wasn't done, which makes every additional type code we use risky because it may collide with a user of this library's custom extensions.

Closes #1240

@AArnott AArnott added this to the v2.4 milestone Apr 26, 2022
@AArnott AArnott requested a review from neuecc April 26, 2022 15:34
Copy link
Copy Markdown
Member

@neuecc neuecc left a comment

Choose a reason for hiding this comment

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

If DateOnly uses DayNumber as int, why not TimeOnly just use Ticks as long?
Seems like a bad idea to use an extension for this.

@AArnott
Copy link
Copy Markdown
Collaborator Author

AArnott commented May 24, 2022

Is it really that appropriate to use a msgpack primitive type to represent a value that isn't meant to be interpreted as a primitive? I'm on the fence at the moment on that point.
But sure, I don't have a strong objection so I'll redo with long ticks for TimeOnly.

@AArnott AArnott force-pushed the fix1240_dateonly branch from 13637a1 to 1974603 Compare May 24, 2022 02:48
@neuecc
Copy link
Copy Markdown
Member

neuecc commented May 24, 2022

Ok, thanks!

@AArnott AArnott force-pushed the fix1240_dateonly branch from 1974603 to 513c198 Compare May 24, 2022 13:31
AArnott and others added 3 commits May 24, 2022 10:08
`DateOnly` requires 5 bytes (typically).
`TimeOnly` requires 6 bytes for second resolution or 8 bytes for ticks resolution. This is automatically selected based on the original value.

Closes MessagePack-CSharp#1240

# Conflicts:
#	src/MessagePack/net6.0/PublicAPI.Unshipped.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants