Skip to content

.Net: [.NET] TimePlugin: add TimeProvider injection for testability #14111

Description

@grvnmttl

TimePlugin currently calls DateTimeOffset.Now directly in all methods, making unit tests depend on the real clock. The test file already has a // TODO: allow clock injection and test all functions comment acknowledging this gap.

Proposed fix: accept a TimeProvider constructor parameter (defaulting to TimeProvider.System), which is the standard .NET pattern for clock abstraction since .NET 8.

I have an implementation ready and will submit a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    .NETIssue or Pull requests regarding .NET codetriage

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions