Member-only story
.NET 8, Top 10 Features You Can’t Miss in 2023
Release Candidate Features
Every time I dive into a new .NET release, I’m like a kid in a candy store, and .NET 8 is no exception.
It feels like Microsoft has been reading my developer wishlist! Serialization upgrades to the beefed-up networking features, .NET 8 is shaping up nicely. So, why am I so excited about this release? Let’s jump in and explore together.
1. Time Abstraction in .NET 8
.NET 8 introduces the TimeProvider
class and ITimer
interface to add time abstraction functionality. This allows developers to mock time in test scenarios. Additionally, you can use the time abstraction to mock Task
operations that rely on time progression using Task.Delay
and Task.WaitAsync
.
Code Examples:
// Get system time.
DateTimeOffset utcNow = TimeProvider.System.GetUtcNow();
DateTimeOffset localNow = TimeProvider.System.GetLocalNow();
// Create a time provider that works with a different time zone
// than the local time…