-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use the new TimeProvider API from .NET 8 #1070
Comments
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made. |
I would also suggest that you use https://www.nuget.org/packages/Microsoft.Bcl.TimeProvider to use TimeProvider for all the .NET versions you are supported. It has been backported to support .netstandard 2.0. |
Btw. I have a few issues with Microsofts FakeTimeProvider implementation, which is why I have kept my own fake around. Basically, their version does not behave consistently depending on how far you advance time. So if you are planing to use their FakeTimeProvider, check out https://github.com/egil/TimeProviderExtensions#difference-between-manualtimeprovider-and-faketimeprovider which explains the problem. |
@egil - We flushed out a bug in preview 6, but otherwise we've not had an real issues with The NuGet package is being used for the down-level frameworks in that PR, which will likely ship as a v8.1.0 once .NET 8 ships (as dotnet/extensions for 8.0.0 depends on us shipping our 8.0.0). That also reminds me I need to update that PR to RC1 (I've been on holiday the last 2 weeks)... |
@martincostello yeah, the In the latest release of Great to hear .NET 6/7 versions of Polly will also use and support TimeProvider. |
@martincostello I just installed Polly v8 and I cannot see any places where I can provide a TimeProvider to Polly, which would allow me to replace it during testing. Are you not allowing Polly users to provide a TimeProvider? |
You can follow #1144 for the changes to support |
Ahh ok, that makes sense. |
We'll look to ship that change as soon as possible after .NET 8 RTM. |
Instead of writing our own variant of
IClock
that allows mocking time in tests we can now leverage the TimeProvider API that will be introduced in .NET 8.The
TimeProvider
will be also available in .NET Framework by referencing the new nuget package.Until the package is ready we can just copy the implementaiton into Polly, mark all classes as internal and once the official package is ready expose
ResilienceStrategyBuilderOptions.TimeProvider
property.Wit this approach we will be using unified time abstraction and also allow easy unit-testing of strategies working with time.
The text was updated successfully, but these errors were encountered: