-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Attempting to rebase #1144 for .NET 8 and to consume TimeProvider from NuGet (and use the new FakeTimeProvider implementation) things get complicated because there are various tests that rely on TimeProvider having a virtual CancelAfter() and Delay() method that can be overridden in the tests.
Polly/src/Polly.Core/ToBeRemoved/TimeProvider.cs
Lines 53 to 57 in a9bf3e9
| // This one is not on TimeProvider, temporarly we need to use it | |
| public virtual Task Delay(TimeSpan delay, CancellationToken cancellationToken = default) => Task.Delay(delay, cancellationToken); | |
| // This one is not on TimeProvider, temporarly we need to use it | |
| public virtual void CancelAfter(CancellationTokenSource source, TimeSpan delay) => source.CancelAfter(delay); |
The real implementation instead has extension methods (which we can't mock) which are TimeProvider.Delay() and TimeProvider.CreateCancellationTokenSource().
To make the switch over for .NET 8 simpler, we should sync the current internal implementation to be source compatible with the .NET 8 rather than rely on methods which won't exist. That way, the tests will not need to change much and the switch over should be a lot cleaner.