Skip to content

[repo-assist] improve: format DateOnly/TimeOnly properties with ISO 8601 in formatObject#468

Merged
sergey-tihon merged 4 commits into
masterfrom
repo-assist/improve-formatobject-dateonly-20260711-83d4619660a09cf6
Jul 11, 2026
Merged

[repo-assist] improve: format DateOnly/TimeOnly properties with ISO 8601 in formatObject#468
sergey-tihon merged 4 commits into
masterfrom
repo-assist/improve-formatobject-dateonly-20260711-83d4619660a09cf6

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

formatObject is the helper emitted as the ToString() override body for all generated API response types. Previously, DateOnly and TimeOnly property values were formatted via obj.ToString(), which uses the ambient CultureInfo — producing locale-specific strings like 7/11/2026 on en-US machines.

This change adds two extra branches to formatObject so DateOnly and TimeOnly values use the same ISO 8601 formats already used by toParam:

Type Before After
DateOnly(2025, 7, 4) 7/4/2025 (locale-specific) 2025-07-04
TimeOnly(14, 30, 0) 2:30 PM (locale-specific) 14:30:00
TimeOnly(9, 5, 3, 123) 9:05 AM (locale-specific) 09:05:03.123

This makes the debug ToString() representation of generated objects:

  • Consistent with the over-the-wire serialisation format
  • Locale-independent (same output on every machine and CI runner)
  • Predictable for users who print generated objects in logs or tests

The existing formatDateOrTimeValue helper (already used by toParam) is reused; no new format logic is introduced.

Changes

  • src/SwaggerProvider.Runtime/RuntimeHelpers.fs: Added DateOnly and TimeOnly branches in formatObject before the generic obj.ToString() fallback.
  • tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs: Added two new fixture types (FmtDateOnly, FmtTimeOnly) and three new [<Fact>] tests in FormatObjectTests.

Test Status

dotnet tests/SwaggerProvider.Tests/bin/Release/net10.0/SwaggerProvider.Tests.dll
Total: 525, Errors: 0, Failed: 0, Skipped: 1, Time: 1.111s

Fantomas format check: ✅ clean. No integration tests required (runtime helper, no provider instantiation).

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@e15e57b40918dbca11b350c55d02ab61934afa75

…bject

formatObject is emitted as the ToString() override body for generated
API response types. Previously DateOnly and TimeOnly property values
were rendered via obj.ToString() which uses locale-specific formatting
(e.g. 7/11/2026 on en-US). Now they use the same ISO 8601 formats as
toParam: yyyy-MM-dd for DateOnly and HH:mm:ss.FFFFFFF for TimeOnly.

This makes the debug representation consistent with what is sent over
the wire and independent of the ambient CultureInfo.

Three new tests cover the new behaviour.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@sergey-tihon sergey-tihon marked this pull request as ready for review July 11, 2026 08:14
Copilot AI review requested due to automatic review settings July 11, 2026 08:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the runtime formatObject helper (used as the emitted ToString() body for generated response types) so DateOnly and TimeOnly property values are formatted using ISO 8601-compatible, culture-invariant formats, aligning the debug representation with the existing toParam formatting behavior.

Changes:

  • Add DateOnly and TimeOnly type branches to formatObject so values format as yyyy-MM-dd and HH:mm:ss.FFFFFFF instead of using culture-dependent ToString().
  • Add unit tests verifying formatObject output for DateOnly and TimeOnly (including sub-second precision).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/SwaggerProvider.Runtime/RuntimeHelpers.fs Adds DateOnly/TimeOnly formatting branches in formatObject using the existing invariant formatDateOrTimeValue helper.
tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs Adds fixtures and tests validating the new formatObject formatting for DateOnly and TimeOnly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/SwaggerProvider.Runtime/RuntimeHelpers.fs

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread src/SwaggerProvider.Runtime/RuntimeHelpers.fs
@sergey-tihon sergey-tihon merged commit 43c878a into master Jul 11, 2026
3 checks passed
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.

3 participants