[repo-assist] improve: format DateOnly/TimeOnly properties with ISO 8601 in formatObject#468
Merged
sergey-tihon merged 4 commits intoJul 11, 2026
Conversation
…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>
Contributor
There was a problem hiding this comment.
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
DateOnlyandTimeOnlytype branches toformatObjectso values format asyyyy-MM-ddandHH:mm:ss.FFFFFFFinstead of using culture-dependentToString(). - Add unit tests verifying
formatObjectoutput forDateOnlyandTimeOnly(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.
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.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
formatObjectis the helper emitted as theToString()override body for all generated API response types. Previously,DateOnlyandTimeOnlyproperty values were formatted viaobj.ToString(), which uses the ambientCultureInfo— producing locale-specific strings like7/11/2026onen-USmachines.This change adds two extra branches to
formatObjectsoDateOnlyandTimeOnlyvalues use the same ISO 8601 formats already used bytoParam:DateOnly(2025, 7, 4)7/4/2025(locale-specific)2025-07-04TimeOnly(14, 30, 0)2:30 PM(locale-specific)14:30:00TimeOnly(9, 5, 3, 123)9:05 AM(locale-specific)09:05:03.123This makes the debug
ToString()representation of generated objects:The existing
formatDateOrTimeValuehelper (already used bytoParam) is reused; no new format logic is introduced.Changes
src/SwaggerProvider.Runtime/RuntimeHelpers.fs: AddedDateOnlyandTimeOnlybranches informatObjectbefore the genericobj.ToString()fallback.tests/SwaggerProvider.Tests/RuntimeHelpersTests.fs: Added two new fixture types (FmtDateOnly,FmtTimeOnly) and three new[<Fact>]tests inFormatObjectTests.Test Status
Fantomas format check: ✅ clean. No integration tests required (runtime helper, no provider instantiation).
Add this agentic workflows to your repo
To install this agentic workflow, run