microsoft / microsoft/aspire

Normalize TimeSpan units in polyglot DTO fixtures

Open
#19,797 1 comment 0 reactions 0 assignees View on GitHub
area-integrations
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

### Is there an existing issue for this?

- [x] I have searched the existing issues

### Describe the bug

The Aspire Type System (ATS) wire contract represents `TimeSpan` numbers as **milliseconds**. `AtsMarshaller.SerializePrimitive` and `ConvertPrimitive` already use milliseconds, and #19008 extends that behavior to `TimeSpan` properties nested inside `[AspireDto]` objects.

Several existing YARP polyglot fixtures instead encode .NET ticks:

- `tests/PolyglotAppHosts/Aspire.Hosting.Yarp/TypeScript/apphost.mts`
- `tests/PolyglotAppHosts/Aspire.Hosting.Yarp/Java/AppHost.java`
- `tests/PolyglotAppHosts/Aspire.Hosting.Yarp/Go/apphost.go`

For example, the TypeScript fixture passes:

```typescript
activityTimeout: 30_000_000,
interval: 50_000_000,
timeout: 20_000_000,
reactivationPeriod: 100_000_000,
```

Those values appear intended to mean 3s, 5s, 2s, and 10s in .NET ticks. Under the established ATS millisecond contract they mean roughly 8h20m, 13h53m, 5h33m, and 27h46m.

This was exposed while reviewing #19008 because that PR adds numeric `TimeSpan` support inside DTO deserialization. The fixtures currently validate generated-language compilation but do not prove the resulting YARP runtime configuration has the intended duration values.

### Expected Behavior

All polyglot AppHost examples and fixtures should use the ATS millisecond representation consistently. YARP DTO values intended as 3s, 5s, 2s, and 10s should be `3_000`, `5_000`, `2_000`, and `10_000` respectively.

Add runtime/round-trip coverage that invokes the DTO-based capability and verifies the resulting C# `TimeSpan` values or generated YARP configuration, so future unit mismatches cannot pass through compile-only tests.

### Steps To Reproduce

1. Generate and run the TypeScript YARP AppHost fixture.
2. Apply the `withForwarderRequestConfig` and `withHealthCheckConfig` DTOs.
3. Inspect the resulting C# DTO or generated YARP configuration.
4. Observe that `30_000_000` is interpreted as 30,000,000 milliseconds rather than three seconds.

Search all polyglot language fixtures for the same tick-shaped constants before completing the fix.

### Exceptions (if any)

N/A

### Aspire doctor output

N/A

### Anything else?

Follow-up from #19008. This should preserve milliseconds as the ATS contract; changing the new DTO converter back to ticks would conflict with existing direct `TimeSpan` marshalling behavior.

Contributor guide

Open the contributing guide

Research direction

Start with tests/PolyglotAppHosts/Aspire.Hosting.Yarp/TypeScript/apphost.mts, Java/AppHost.java, and Go/apphost.go, then search the other polyglot fixtures for tick-shaped TimeSpan constants. Run the existing fixture tests and add runtime or round-trip coverage for the DTO-based capability. Done means the fixtures use millisecond values and the resulting C# TimeSpan or YARP configuration confirms the intended durations.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, go, java, typescript
Domain
backend-api-design, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.