Skip to content

fix: refuse an hour of 24 in temporal text on the .NET 11 runtime too - #308

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/300-hour-24-on-net11-runtime
Oct 19, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/300-hour-24-on-net11-runtime

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #300. The issue is closed by hand after the merge, because Closes acts only on main.

Based on release/10.x after #305 (opens 10.1.0) and #306 merged; the ### Changed answers section sits above #306's ### Fixed in the root changelog. The fix exists on main in #292 (commit 231f23a, issue #286 on the 11 line) and is ported here by hand.

Problem

IsoTemporal hands element text to TimeOnly.TryParseExact, DateTime.TryParseExact and DateTimeOffset.TryParseExact. .NET 11 accepts an hour of 24 there where .NET 10 refuses it. The 10.x packages target net10.0, but a net11.0 application that references them runs them on the .NET 11 runtime, so the released 10.0.0 reads {24:00:00} as {00:00:00} and T24:00:00 as the next day's midnight there, silently, while throwing FormatException on .NET 10. Measured again with the published 10.0.0 package, one net10.0 build run on both runtimes:

Call .NET 10.0.13 .NET 11.0.0-rc.2
TimeSet.Parse("{24:00:00}") FormatException {00:00:00.0000000}
TimeSet.TryParse("{24:00:00}") false {00:00:00.0000000}
DateTimeRange.Parse("[2026-01-01 00:00:00,2026-01-01T24:00:00)") FormatException [2026-01-01T00:00:00.0000000,2026-01-02T00:00:00.0000000)
DateTimeOffsetRange.Parse("[2026-01-01 00:00:00Z,2026-01-01T24:00:00Z)") FormatException [2026-01-01T00:00:00.0000000+00:00,2026-01-02T00:00:00.0000000+00:00)
JSON ["24:00:00"] as TimeSet JsonException {00:00:00.0000000}

Change

Tests

The defect is visible only on the .NET 11 runtime, so the proof runs the net10.0 core test assembly twice: on the SDK's .NET 10.0.13 through dotnet test, and on .NET 11.0.0-rc.2 (installed with dotnet-install.sh --channel 11.0 --quality preview --runtime dotnet) by running the SDK's vstest.console.dll under that host with --roll-forward Major, which the test host's diagnostic log confirms (Runtime location: …/dotnet11/shared/Microsoft.NETCore.App/11.0.0-rc.2.26504.105). Plain dotnet test with DOTNET_ROOT set does not reach the test host: VSTest launches it from the muxer that runs vstest.console, so that run stays on .NET 10 and passes.

TemporalLiteralGrammarTests, --filter FullyQualifiedName~TemporalLiteralGrammarTests:

State .NET 10.0.13 .NET 11.0.0-rc.2
10.0.0 code, before this PR (109 rows) 109 pass 1 fails: Time_Rejects("24:00:00")
new rows, source fix reverted (115 rows) 115 pass 7 fail: Time_Rejects("24:00:00"), Time_Rejects("24:00"), Time_Rejects("24:00:00.0"), DateTime_Rejects("2027-02-01T24:00:00"), DateTime_Rejects("2027-02-01 24:00"), DateTimeOffset_Rejects("2026-01-01T24:00:00Z"), DateTimeOffset_Rejects("2026-01-01 24:00:00+05:30:00")
this PR (115 rows) 115 pass 115 pass

The failure on .NET 11 without the fix:

Fehler Time_Rejects ("24:00:00") [3 ms]
  Assertion failed. Expected exception of exact type FormatException but no exception was thrown.
  Assert.ThrowsExactly<FormatException>(() => TimeRange.ParseValue(text, null))

With the fix, the whole core project (1397 tests) passes on both runtimes. Also green locally: the conventions tests (403, including ChangelogConventionTests and the claim catalogue), the ASP.NET Core host tests (92), the NodaTime tests (238) and both EF Core translation projects (289 and 83). .github/scripts/pr-hygiene.sh on an event with this PR's labels passes, and fails with the expected message when the ### Changed answers heading is renamed.

CI on the 10.x line cannot see this defect until #297 adds a .NET 11 runtime roll-forward leg; TemporalLiteralGrammarTests.Time_Rejects("24:00:00") is the row that fails there today.

🤖 Generated with Claude Code

IsoTemporal handed element text to TimeOnly.TryParseExact, DateTime.TryParseExact and
DateTimeOffset.TryParseExact. .NET 11 accepts an hour of 24 there where .NET 10 refuses
it, and this net10.0 assembly runs on the .NET 11 runtime inside a net11.0 application,
so the released 10.0.0 read `{24:00:00}` as `{00:00:00}` and `T24:00:00` as the next
day's midnight there, silently, while throwing FormatException on .NET 10.

IsoTemporal now refuses an hour of 24 before the BCL parse, for a time, a DateTime and
a DateTimeOffset, so a literal means the same on every runtime. Ported by hand from
PR #292 (231f23a, the #286 fix on main), with the TemporalLiteralGrammarTests rows
`24:00`, `24:00:00.0`, `T24:00:00`, ` 24:00`, `T24:00:00Z` and ` 24:00:00+05:30:00`.

Proved on the .NET 11.0.0-rc.2 runtime, the net10.0 test assembly run under
vstest.console with --roll-forward Major: without the fix Time_Rejects("24:00:00") and
the six new rows fail (7 of 115); with it all 115 pass, and the whole core project
passes on .NET 10.0.13 and 11.0.0-rc.2 alike. On .NET 10 the rows pass both ways.

A silent fix, so 10.1.0 is a minor: the root and core changelogs open the 10.1.0
section with "Changed answers", one row linking #300 and the new "Changed answers in
10.1.0" section of docs/migration.md, which says how to find the text whose reading
changed. docs/serialization.md's grammar list names the rule.

Found-By: OT
Defect-Class: LIT
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.1.0 milestone Oct 19, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred area/literals Parse, TryParse and formatting package/core Affects CodoMetis.ValueRanges severity/medium Inconsistency or failure in a narrow scenario labels Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit b74064a into release/10.x Oct 19, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/300-hour-24-on-net11-runtime branch October 19, 2026 12:09
CaffeinatedCoder pushed a commit that referenced this pull request Oct 19, 2026
Resolves the core changelog conflict with #308: the 10.1.0 section opens with
Changed answers (#300), then Fixed (#299).

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/literals Parse, TryParse and formatting bug Something isn't working package/core Affects CodoMetis.ValueRanges severity/medium Inconsistency or failure in a narrow scenario silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant