Skip to content

[NOT-STREAM] fix: encode a WIT duration in JSON as proto3 in .NET and TypeScript - #67

Closed
moetemp wants to merge 2 commits into
moe/up/python-json-durationfrom
moe/up/json-duration-dotnet-typescript
Closed

moetemp wants to merge 2 commits into
moe/up/python-json-durationfrom
moe/up/json-duration-dotnet-typescript

Conversation

@moetemp

@moetemp moetemp commented Oct 23, 2026

Copy link
Copy Markdown
Owner

What changed?

This PR writes and reads a WIT duration in a WIT-only (JSON) record in the proto3 JSON form, such as "1.5s", in .NET and TypeScript, as Python does.

  • .NET: a TimeSpan or TimeSpan? property of such a model gets a JsonConverter for the proto3 form.
  • TypeScript: an operation whose input or output holds a duration gets a transfer type converter. It always writes the string form, and it reads the string form and a number of milliseconds, so old payloads still decode.

Why?

.NET wrote "00:00:01.5000000", and TypeScript wrote whatever the caller gave, so the languages couldn't read each other's durations.

How did you test it?

The stream-service .NET and TypeScript goldens show the converters on CreateStreamRequest and ReadRecordsRequest. A sample test in each language round-trips wait and checks that the JSON text has "0.25s".

Based on fork PR #65.

@moetemp moetemp changed the title [UPSTREAM-15] fix: encode a WIT duration in JSON as proto3 in .NET and TypeScript [NOT-STREAM] fix: encode a WIT duration in JSON as proto3 in .NET and TypeScript Oct 23, 2026
@moetemp

moetemp commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Closed as NOT-STREAM. Every streaming duration is in a proto-backed record, so it never goes through the JSON converter.

@moetemp moetemp closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant