Skip to content

Releases: egil/TimeProviderExtensions

v1.0.0

14 Nov 21:03
Compare
Choose a tag to compare

This is the first none-preview release. It upgrades all dependencies to none-preview versions. Otherwise, there are no changes.

v1.0.0-rc.3

12 Nov 23:39
Compare
Choose a tag to compare
v1.0.0-rc.3 Pre-release
Pre-release

Strong named the assembly. By @quinmars.

v1.0.0-rc.2

25 Sep 14:11
Compare
Choose a tag to compare
v1.0.0-rc.2 Pre-release
Pre-release
  • Added ActiveTimers property to ManualTimeProvider. The property will display the number of currently active timers that have a callback scheduled to be called in the future.

  • Allow ManualTimeProvider.Start to be set using property initializers.

  • Made the timer type created by ManualTimeProvider, the ManualTimer type, public, and introduced a protected method CreateManualTimer on ManualTimeProvider. This enables advanced scenarios where a custom ManualTimer is needed.

    A custom implementation of ManualTimer can override the Change method and add custom behavior to it.

    Overriding CreateManualTimer makes it possible to intercept a TimerCallback and perform actions before and after the timer callback has been invoked.

  • Replace the AutoAdvanceAmount property with the AutoAdvanceBehavior property on ManualTimeProvider, and introduce the AutoAdvanceBehavior type. To automatically advance the time when GetUtcNow() or GetLocalNow() is called, set AutoAdvanceBehavior.UtcNowAdvanceAmount to a TimeSpan larger than zero.

  • Enable auto advance feature for GetTimestamp() and GetElapsedTime(long). To automatically advance the time when GetTimestamp() or GetElapsedTime(long) is called, set AutoAdvanceBehavior.TimestampAdvanceAmount to a TimeSpan larger than zero.

  • ManualTimer now exposes its current configuration. DueTime, Period, IsActive, CallbackTime, and CallbackInvokeCount are now publicly visible.

  • Enable auto-advance feature for timers. This enables automatically calling timers callback a specified number of times, by setting the AutoAdvanceBehavior.TimerAutoTriggerCount property to a number larger than zero.

Full Changelog: v1.0.0-rc.1...v1.0.0-rc.2

v1.0.0-rc.1

19 Sep 10:39
Compare
Choose a tag to compare
v1.0.0-rc.1 Pre-release
Pre-release
  • Updated Microsoft.Bcl.TimeProvider package dependency to rc.1 version.

v1.0.0-preview.7

11 Sep 12:22
Compare
Choose a tag to compare
v1.0.0-preview.7 Pre-release
Pre-release

v1.0.0-preview.6

04 Sep 23:23
909271c
Compare
Choose a tag to compare
v1.0.0-preview.6 Pre-release
Pre-release
  • Added Jump(TimeSpan) and Jump(DateTimeOffset) methods that will jump time to the specified place. Any timer callbacks between the start and end of the jump will be invoked the expected number of times, but the date/time returned from GetUtcNow() and GetTimestamp() will always be the jump time. This differs from how Advance and SetUtcNow works. See the readme for a detailed description.

v1.0.0-preview.5

21 Aug 13:05
Compare
Choose a tag to compare
v1.0.0-preview.5 Pre-release
Pre-release

Aligned the public API surface of ManualTimeProvider with Microsoft.Extensions.Time.Testing.FakeTimeProvider. This means:

  • The StartTime property is now called Start.
  • The ForwardTime method has been removed (use Advance instead).
  • The AutoAdvanceAmount property has been introduced, which will advance time with the specified amount every time GetUtcNow() is called. It defaults to TimeSpan.Zero, which disables auto-advancing.

v1.0.0-preview.4

24 May 21:46
Compare
Choose a tag to compare
v1.0.0-preview.4 Pre-release
Pre-release
  • Added 'StartTime' to ManualTestProvider, which represents the initial date/time when the ManualtTimeProvider was initialized.

v1.0.0-preview.3

24 May 13:56
Compare
Choose a tag to compare
v1.0.0-preview.3 Pre-release
Pre-release
  • Changed ManualTestProvider sets the local time zone to UTC by default, provides method for overriding during testing.
  • Changed ManualTestProvider.ToString() method to return current date time.
  • Fixed ITimer returned by ManualTestProvider such that timers created with a due time equal to zero will fire the timer callback immediately.

v1.0.0-preview.2

20 May 09:17
Compare
Choose a tag to compare
v1.0.0-preview.2 Pre-release
Pre-release

This release adds a dependency on Microsoft.Bcl.TimeProvider and utilizes the types built-in to that to do much of the work.

Compared to the previous version (TimeScheduler) of this library, this release includes the following changes:

  • Removed CancelAfter extension methods. Instead, create a CancellationTokenSource via the method TimeProvider.CreateCancellationTokenSource(TimeSpan delay) or in .NET 8, using new CancellationTokenSource(TimeSpan delay, TimeProvider timeProvider).

    NOTE: If running on .NET versions earlier than .NET 8.0, there is a constraint when invoking CancellationTokenSource.CancelAfter(TimeSpan) on the resultant object. This action will not terminate the initial timer indicated by delay. However, this restriction does not apply on .NET 8.0 and later versions.

Known issues and limitations:

  • When using the ManualTimeProvider during testing to forward time, be aware of this issue: dotnet/runtime#85326.
  • If running on .NET versions earlier than .NET 8.0, there is a constraint when invoking CancellationTokenSource.CancelAfter(TimeSpan) on the CancellationTokenSource object returned by CreateCancellationTokenSource(TimeSpan delay). This action will not terminate the initial timer indicated by the delay argument initially passed the CreateCancellationTokenSource method. However, this restriction does not apply on .NET 8.0 and later versions.
  • To enable controlling PeriodicTimer via TimeProvider in versions of .NET earlier than .NET 8.0, the TimeProvider.CreatePeriodicTimer returns a PeriodicTimerWrapper object instead of a PeriodicTimer object. The PeriodicTimerWrapper type is just a lightweight wrapper around the original System.Threading.PeriodicTimer and will behave identically to it.