Repository navigation
Write DateTimeOffset, DateOnly, TimeOnly and Version values as one scalar [patch] - #220
Merged
Merged
Conversation
…alar [patch] The shared serializer had no converters for these types, so YamlDotNet wrote each one as a mapping of its public properties. A DateTimeOffset date came out as about 20 keys that site generators cannot read. They now go through one invariant converter: - DateTimeOffset is written plain as an ISO 8601 round-trip timestamp. - DateOnly is written as yyyy-MM-dd. - TimeOnly is written as a double-quoted HH:mm:ss[.fffffff], because YAML 1.1 reads a plain 10:30:00 as a base-60 number. - Version is written as a string, which quotes one such as 1.10 that would otherwise read back as a number. None of them depend on the current culture. Fixes #217 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4yhNfJ8wLeTtjP3L1
…overage gate The converter is registered on the serializer only, so ReadYaml never ran; it now throws NotSupportedException. Version takes the default branch, which no longer needs a separate null case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW4yhNfJ8wLeTtjP3L1
|
This was referenced Oct 31, 2026
matt-edmondson
pushed a commit
that referenced
this pull request
Oct 31, 2026
CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3
matt-edmondson
pushed a commit
that referenced
this pull request
Oct 31, 2026
CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b)
matt-edmondson
pushed a commit
that referenced
this pull request
Oct 31, 2026
CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b)
matt-edmondson
pushed a commit
that referenced
this pull request
Nov 2, 2026
CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b)
matt-edmondson
pushed a commit
that referenced
this pull request
Nov 2, 2026
CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b)
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
…h] (#226) CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 Co-authored-by: Claude <noreply@anthropic.com>
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
…227) * Keep keys in input order when CombineFrontmatter merges them [patch] MergeSimilarProperties wrote its output one canonical-name group at a time, so a later key that shares a canonical name with an earlier one moved up next to it, even when the two were kept apart (different value types). FrontmatterOrder.AsIs then did not keep the document's order, and under Sorted a second run reordered the keys again. The merged dictionary is now put back in input order: a key that keeps its own name keeps its own position, and a merged key takes the position of the first member merged into it. Adds both reproductions from the issue and seeded tests for AsIs order and idempotence across every merge strategy. Fixes #224 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 * Give the caller-value serializer the invariant scalar converter [patch] CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 --------- Co-authored-by: Claude <noreply@anthropic.com>
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
* Quote caller strings that read back as floats, = or << [patch] AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter now double-quote caller strings matching the YAML 1.2 float pattern (1e3, 2e10, 1.5e3), which quoteYaml1_1Strings left plain since #216, and strings equal to = or <<, which PyYAML's safe_load cannot construct. Fixes #228 Fixes #230 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2dKE2suWaWTkfYf74 * Apply the lookalike quoting on both serializers so the builder setup stays as it was Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2dKE2suWaWTkfYf74 * Give the caller-value serializer the invariant scalar converter [patch] CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b) --------- Co-authored-by: Claude <noreply@anthropic.com>
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
* Resolve only a plain << as a YAML merge key [patch] A single- or double-quoted "<<" key is an ordinary string key in YAML 1.1, PyYAML and js-yaml. Deserialize through a parser that swaps a quoted << scalar for a stand-in, so ResolveMergeKeys no longer flattens its contents into the parent, and turn the stand-in back into << on conversion. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW2dKE2suWaWTkfYf74 * Give the caller-value serializer the invariant scalar converter [patch] CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b) --------- Co-authored-by: Claude <noreply@anthropic.com>
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
…nts [patch] (#236) * Insert a double or decimal into the header without dropping its comments [patch] TryInsertIntoHeader compared the header it read back against the caller's raw values, but this library's reader reads numbers lossily, so a double that isn't exact in float32 (51.507351) or a decimal with a trailing zero (9.90m) never compared equal. The insert was rejected and the header was rebuilt, dropping its comments and requoting existing values. The expected properties are now the existing ones plus the added keys as the reader reads their written text back, so both sides of the check go through the same reader. Fixes #234 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW6SmLTCjq6sfKLU8dj * Give the caller-value serializer the invariant scalar converter [patch] CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b) --------- Co-authored-by: Claude <noreply@anthropic.com>
matt-edmondson
added a commit
that referenced
this pull request
Nov 4, 2026
…itten [patch] (#237) * Keep values a header already holds as written when the header is rewritten [patch] ReplaceFrontmatter, and AddFrontmatter's rebuild fallback through it, wrote every value with the caller-value serializer, which quotes YAML 1.1 lookalikes. A value read from the document, such as published: no, came back as the truthy string "no", so a Jekyll draft got published. Values that serialize the same as the existing header's value for the key are now written with the document serializer; only changed or added values get YAML 1.1 quoting. Fixes #233 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW6SmLTCjq6sfKLU8dj * Give the caller-value serializer the invariant scalar converter [patch] CallerValueSerializer, added in #216, was built without the InvariantScalarTypeConverter that #220 gave the shared Serializer, so AddFrontmatter, ReplaceFrontmatter and SerializeFrontmatter wrote DateTimeOffset, DateOnly, TimeOnly and Version values as mappings of their properties again, and main failed 7 InvariantScalarTypeTests. Both serializers now start from one CreateSerializerBuilder, so only their string quoting differs and the next shared option cannot be left off one of them. Adds tests for ReplaceFrontmatter, SerializeFrontmatter and values inside a list. Fixes #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5WhwpCJojPcgRgxL3 (cherry picked from commit 06f270b) --------- Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Nov 16, 2026
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.



Fixes #217
What changed
The shared
SerializerinYamlSerializer.csnow has anInvariantScalarTypeConverterregistered. It writes each of these types as a single scalar instead of a mapping of its CLR properties:DateTimeOffset2024-01-15T10:30:00.0000000+02:00, plain ISO 8601 round-trip, so Jekyll and Hugo read it as a timestampDateOnly(.NET 6+)2024-01-15TimeOnly(.NET 6+)"10:30:00"or"10:30:05.25", double-quoted because YAML 1.1 reads a plain10:30:00as the base-60 number 37800VersionToString(), written as a string, so1.10is quoted rather than read back as the number1.1All formats use
CultureInfo.InvariantCulture. YamlDotNet's ownDateOnlyConverteruses the current culture, which is why this PR doesn't use it.This covers every path that writes through the serializer:
AddFrontmatter, both when it creates a header and when it inserts into an existing oneReplaceFrontmatterSerializeYamlObjectTests
Frontmatter.Test/InvariantScalarTypeTests.csadds 8 cases. They run under a non-invariant culture that uses.for times and,for decimals. The culture is cloned from the invariant one, so the tests also run where globalization-invariant mode is on and named cultures likede-DEaren't available.The cases check:
ExtractFrontmatterreads the value back as one scalar.With the converter reverted, all 8 fail. The full suite passes: 377/377 on net10.0. The library also builds for netstandard2.0/2.1 and net8/9/10, where
DateOnly/TimeOnlyare behindNET6_0_OR_GREATER.Notes
ExtractFrontmatterreturns the written scalar in whatever form the deserializer already resolves it to.main.🤖 Generated with Claude Code
https://claude.ai/code/session_017vfJW4yhNfJ8wLeTtjP3L1