Use TimeToLive (TimeSpan?) instead of TtlMs (long?) in public APIs (#1644)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: PranavSenthilnathan <12225508+PranavSenthilnathan@users.noreply.github.com>
Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
Co-authored-by: Pranav Senthilnathan <pranas@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Copilot 2026-06-23 09:12:15 -07:00 • committed by GitHub
commit 3368bb7349
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 30 additions and 85 deletions

View file

@ -55,10 +55,11 @@ public sealed class CreateTaskResult : Result
public required DateTimeOffset LastUpdatedAt { get; set; }
/// <summary>
/// Gets or sets the time-to-live duration from creation in milliseconds, or <see langword="null"/> for unlimited.
/// Gets or sets the time-to-live duration from creation, or <see langword="null"/> for unlimited.
/// </summary>
[JsonPropertyName("ttlMs")]
public long? TtlMs { get; set; }
[JsonConverter(typeof(TimeSpanMillisecondsConverter))]
public TimeSpan? TimeToLive { get; set; }
/// <summary>
/// Gets or sets the suggested polling interval in milliseconds.

View file

@ -64,10 +64,10 @@ public abstract class GetTaskResult : Result
public required DateTimeOffset LastUpdatedAt { get; set; }
/// <summary>
/// Gets or sets the time-to-live duration from creation in milliseconds, or <see langword="null"/> for unlimited.
/// Gets or sets the time-to-live duration from creation, or <see langword="null"/> for unlimited.
/// </summary>
[JsonPropertyName("ttlMs")]
public long? TtlMs { get; set; }
public TimeSpan? TimeToLive { get; set; }
/// <summary>
/// Gets or sets the suggested polling interval in milliseconds.
@ -245,7 +245,7 @@ public abstract class GetTaskResult : Result
};
taskResult.StatusMessage = statusMessage;
taskResult.TtlMs = ttlMs;
taskResult.TimeToLive = ttlMs is null ? null : TimeSpan.FromMilliseconds(ttlMs.Value);
taskResult.PollIntervalMs = pollIntervalMs;
taskResult.ResultType = resultType;
taskResult.Meta = meta;
@ -287,9 +287,9 @@ public abstract class GetTaskResult : Result
writer.WriteString("createdAt", value.CreatedAt);
writer.WriteString("lastUpdatedAt", value.LastUpdatedAt);
if (value.TtlMs is not null)
if (value.TimeToLive is not null)
{
writer.WriteNumber("ttlMs", value.TtlMs.Value);
writer.WriteNumber("ttlMs", (long)value.TimeToLive.Value.TotalMilliseconds);
}
if (value.PollIntervalMs is not null)

View file

@ -70,10 +70,10 @@ public abstract class TaskStatusNotificationParams : NotificationParams
public required DateTimeOffset LastUpdatedAt { get; set; }
/// <summary>
/// Gets or sets the time-to-live duration from creation in milliseconds, or <see langword="null"/> for unlimited.
/// Gets or sets the time-to-live duration from creation, or <see langword="null"/> for unlimited.
/// </summary>
[JsonPropertyName("ttlMs")]
public long? TtlMs { get; set; }
public TimeSpan? TimeToLive { get; set; }
/// <summary>
/// Gets or sets the suggested polling interval in milliseconds.
@ -247,7 +247,7 @@ public abstract class TaskStatusNotificationParams : NotificationParams
};
notification.StatusMessage = statusMessage;
notification.TtlMs = ttlMs;
notification.TimeToLive = ttlMs is null ? null : TimeSpan.FromMilliseconds(ttlMs.Value);
notification.PollIntervalMs = pollIntervalMs;
notification.Meta = meta;
@ -283,9 +283,9 @@ public abstract class TaskStatusNotificationParams : NotificationParams
writer.WriteString("createdAt", value.CreatedAt);
writer.WriteString("lastUpdatedAt", value.LastUpdatedAt);
if (value.TtlMs is not null)
if (value.TimeToLive is not null)
{
writer.WriteNumber("ttlMs", value.TtlMs.Value);
writer.WriteNumber("ttlMs", (long)value.TimeToLive.Value.TotalMilliseconds);
}
if (value.PollIntervalMs is not null)