Skip to content

Too many ISystemClock definitions #16844

@YohDeadfall

Description

@YohDeadfall

The ISystemClock defines a way to get the current time in UTC timezone, and it has a simple implementation:

public interface ISystemClock
{
    DateTimeOffset UtcNow { get; }
}

public interface SystemClock : ISystemClock
{
    public DateTimeOffset UtcNow => DateTimeOffset.UtcNow;
}

The interface exists in:

  • Microsoft.AspNetCore.Authentication
  • Microsoft.AspNetCore.ResponseCaching
  • Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure
  • Microsoft.Extensions.Internal

There is a small difference exists between implementations, but in most cases it can be moved out. In case of Kestrel's clock which has a specific logic inside, there could be made a new interface IScopedSystemClock which will provide the scope start time as UtcNow does now. Therefore, looks like all of them could be merged into a single class/interface and put into Microsoft.Extensions.Primitives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-authIncludes: Authn, Authz, OAuth, OIDC, Bearerarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewaresclean-upThis issue is internal clean-up and has no effect on public APIs or expected behaviorsfeature-platformDeprecated: Cross-cutting issues related to ASP.NET Core as a platform

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions