The .NET Stacks #51: 👷‍♂️ The excitement is Build-ing

This week, we get ready for Microsoft Build, talk more about .NET 6 Preview 4, and more.

Dave Brock
Dave Brock

NOTE: This is the web version of my weekly newsletter, released on May 24, 2021. To get the issues right away, subscribe at dotnetstacks.com or the bottom of this post.

Happy Monday! I hope you're all doing well.

Here's what's going on this week:

  • The big thing: Previewing the big week ahead
  • The little things: SecureString meeting its demise, the .NET Coding Pack, web dev news
  • Last week in the .NET world

The big thing: Previewing the big week ahead

This week will be a big one: we've got Microsoft Build—probably the last virtual one—which kicks off on Tuesday. In what is surely not coincidental timing, .NET 6 Preview 4 should also be released. (And if that isn't enough, The .NET Stacks turns 1 next Monday. Please, no gifts.)

While Build doesn't carry the same developer excitement as it has in the past, in my opinion—the frenetic pace of .NET keeps us busy throughout the year, and, to me, Build has shifted toward a marketing event. Still, it'll be nice to watch some sessions and see where things are going. You can check out the sessions on the Build website.  I'll be keeping an eye on a .NET 6 deep dive, microservices with Dapr, and an Ask the Experts panel with many Microsoft .NET folks.

Next week, we'll also see the release of .NET 6 Preview 4 (finally!). While we'll pore over some of it next week when its formally communicated, the "what's new" GitHub issue really filled up this week and has some exciting updates.

New LINQ APIs

.NET 6 Preview 4 will include quite a few new LINQ APIs.

Index and Range updates

LINQ will now see Enumerable support for Index and Range parameters. The Enumerable.ElementAt method will accept indices from the end of the enumerable, like this:

Enumerable.Range(1, 10).ElementAt(^4); // returns 7

Also, an Enumerable.Take overload will accept Range parameters, which allows you to slice enumerable sequences easily.

MaxBy and MinBy

The new MaxBy and MinBy methods allow you to use a key selector to find a maximum or minimum method, like this (the example here is taken from the issue):

var people = new (string Name, int Age)[] { ("Tom", 20), ("Dick", 30), ("Harry", 40) };
people.MaxBy(person => person.Age); // ("Harry", 40)

Chunk

A new Chunk method allows you to chunk elements into a fixed size, like this (again, taken from the issue):

IEnumerable<int[]> chunks = Enumerable.Range(0, 10).Chunk(size: 3); // { {0,1,2}, {3,4,5}, {6,7,8}, {9} }

New DateOnly and TimeOnly structs

We talked about this in a past issue, but we'll see some new DateOnly and TimeOnly structs that add to DateTime support and do not deprecate what already exists. They'll be in the System namespace, as the others are. For use cases, think of DateOnly for business days and birthdays and TimeOnly for things like recurring meetings and weekly business hours.

Writing DOMs with System.Text.Json

So, this is fun: Preview 4 will bring us the ability to use a writable DOM feature with System.Text.Json. There's quite a few use cases here. A big one is when you want to modify a subset of a large tree efficiently. For example, you'll be able to navigate to a subsection of a large JSON tree and perform operations from that subsection.

There's a lot more with Preview 4. Check out the GitHub issue for the full details. We'll cover more next week.


The little things: SecureString meeting its demise, the .NET Coding Pack, general web dev news

The SecureString API seems great, it really does. It means well. It allows you to flag text as confidential and provide an extra layer of security. The main driver is to avoid using secrets as plain text in a process's memory. However, this doesn't translate to the OS, even on Windows. Except for .NET Framework, array contents are passed around unencrypted. It does have a shorter lifetime, so there's that—but it isn't that secure. It's easy to screw up and hard to get right.

The .NET team has been trying to phase out SecureString for awhile in favor of a more flexible ShroudedBuffer<T> type. This issue comment has all the juicy details of the latest updates.


This week, Scott Hanselman wrote about the .NET Coding Pack for Visual Studio Code. The pack includes an installation of VS Code, the .NET SDK (and adding it to the PATH), and a .NET extension. With the .NET Coding Pack, beginners will be able to work with .NET Interactive notebooks to quickly get started.


While we mostly talk about .NET around here, I think it's important to reach outside our bubble and keep up with web trends. I came across two interesting developments last week.

Google has decided to no longer give Accelerated Mobile Pages (AMP) preferential treatment in its search results (and they are even removing the icon from the results page). Whatever the reason—its controversy, lack of adoption, or Google's anti-trust pressure—it's a welcome step for an independent web. (Now, if only they'd bring back Google Reader.)

In other news, StackBlitz—in cooperation with Google Chrome and Vercel—has launched WebContainers, a way to run Node.js natively in your browser.  Simply put, it's providing an online IDE. Thanks to the strides WebAssembly has made in the past few years, it's paved a way for a WASM operating system.

Under the covers, it includes a virtualized network stack that maps to the browser's ServiceWorker API, which enables offline support. It provides a leg up over something like Codespaces or various REPL solutions, which typically need a server. I take exception with StackBlitz saying those solutions "provide a worse experience than your local machine in nearly every way" ... but if you do any JavaScript work, this is an exciting development (especially when dealing with JS's notoriously cumbersome tooling and setup demands).


🌎 Last week in the .NET world

🔥 The Top 3

📢 Announcements

📅 Community and events

🌎 Web development

🥅 The .NET platform

⛅ The cloud

📔 Languages

🔧 Tools

🏗 Design, testing, and best practices

🎤 Podcasts

🎥 Videos

.NET Stacks

Consider subscribing to The .NET Stacks, my free weekly newsletter. I write about news and trends, interview community leaders, and catch you up fast. (No spam, ever, and unsubscribe whenever you want.)


    Consider subscribing to The .NET Stacks, my free weekly newsletter. I write about news and trends, interview community leaders, and catch you up fast. (No spam, ever, and unsubscribe whenever you want.)