Skip to content

Update TimeProvider documentation to mention how it should be added to the DI #9772

Open
@bfondu

Description

@bfondu

There appears to be very little documentation on the new TimeProvider functionality. I had to go google around to see how this thing was expected to be registered in the DI.

Eventually I did find that I had to do this:
services.TryAddSingleton(TimeProvider.System);

Sadly, this doesn't seem to be documented anywhere. It might be good to at least mention it as a remark on the System.TimeProvider page.

Additionally, I think it would make sense to provide an extension method on IServiceCollection along the lines of AddTimeProvider(), like for example AddHttpContextAccessor() and AddMemoryCache().

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri3Indicates issues/PRs that are low priorityarea-System.DateTimeuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions