As usual, there are a boatload of new APIs coming in .NET 6. Most of these are driven by custom requests. Lets talk about some of them. #dotnet #aspnetcore
In .NET 6, there's a new low-level API to enable reading/writing of files without using a FileStream. It also supports scatter/gather IO (multiple buffers) and overlapping reads and writes at a given file offset.
There are a couple of new ways to access a process path and process id without allocating a new process object:
Generating random numbers from a CSPNG (Cryptographically Secure Pseudorandom Number Generator) is a little easier:
We finally added Parallel.ForEachAsync, a way to schedule asynchronous work that allows you to control the degree of parallelism:
We added a helper to make it easier to throw if a required section of configuration is missing:
There's a ton of new LINQ methods as well. It got lots of love in this release. Here's a new helper to chunk any IEnumerable<T> into batches:
Don't keep bit math in your head? Me neither, here are some new helpers for working with powers of 2:
There's now a much easier (and properly implemented) way to wait for task to complete asynchronously. The following code will yield the await if it hasn't completed in 10 seconds. The operation might still be running! This is for un-cancellable operations!
More LINQ! There are now MaxBy and MinBy methods:
We added an entirely new metrics API based on @opentelemetry in .NET 6. It supports dimensions, is *super* efficient and will have exporters for popular metric sinks (prometheus etc).
OK that's it for now! Enjoy playing with .NET 6 previews and we love you feedback.
OK one more (I posted this a while back). Native support for Posix signal handling. We also emulate a couple of signals on windows.
Oh wait this is one coming in preview7 I should mention. You can all delete your helper methods that do this now 😅.
If you feel like using C APIs to allocate memory because you're a l33t hacker or you need to need to allocate native memory, the look no further. Don't forget to free!
Last but not least, a modern timer API (I think this is the 5th timer API in .NET now). It's fully async and isn't plagued by the types of gotchas the other timers are plagued with like object lifetime issues, no asynchronous callbacks etc.
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.