temporalio / sdk-dotnet

Temporal .NET SDK
MIT License
375 stars 30 forks source link

[Feature Request] Replace `System.TimeProvider` in workflows #307

Open cretz opened 1 month ago

cretz commented 1 month ago

Describe the solution you'd like

There is now a .NET API for creating timers and getting current time. Leverage it. See https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider. Will have to see how it may affect versions we release packages for. https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.TimeProvider.Testing seems to support .NET 6 probably by way of Microsoft.Bcl.TimeProvider inclusion.

Note, while we should provide a Workflow.TimeProvider property, there does not seem to be an obvious way to change the default time provider.

Sushisource commented 1 month ago

there does not seem to be an obvious way to change the default time provider.

Nor should we, I think (other than to just make it throw an error), consistent with the idea that we probably want to avoid magic.