I know I'm a day or so late. Sorry, I was reading about Web 3.0 and still don't know what it is. Do you? After reading this, it made me want to cry, laugh, and then cry again. As if Dapr and Dapper isn't enough, now we have "dapps."
Anyway, here's what we have going on this week (or last week):
- Who moved my cheese: New templates for .NET 6 might surprise you
- Community spotlight: Marten v4 is now live
- Last week in the .NET world
Who moved my cheese: New templates for .NET 6 might surprise you
As the release of .NET 6 is rapidly approaching—with .NET 6 RC2 coming out very soon with the official release next month—you might be taken aback by C# template changes. The .NET team is leveraging top-level statements and implicit using directives for some new .NET 6 templates. For example, top-level statements are helping to drive new capabilities like Minimal APIs. Microsoft has put together a new document, New C# templates generate top-level statements, and you should check it out.
With .NET 6, if you create a new console app using dotnet new console
(or from Visual Studio tooling), you might expect to see this:
using System;
namespace MyVerboseApp
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}
Think again. You'll see this instead:
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
Much like with top-level statements, you probably have one of two opinions: it eliminates boilerplate and makes it simpler and more beginner-friendly; or it provides too many abstractions and "I didn't ask for this." I do like top-level statements and agree it eliminates a lot of boilerplate. When it comes to using args
, though, I like to see where they are being passed in and not just a magic variable.
As of now, to stay consistent with Microsoft pushing to make C# more concise and accessible, it looks like this will be the default template. You can always use the "old" program style from the terminal using framework
and target-framework-override
flags. This allows you to use the "old" template but force the project framework to be .NET 6.0. (It would have been simpler to pass in --leave-my-stuff-alone
, but I digress.)
dotnet new console --framework net5.0 --target-framework-override net6.0
In terms of the tooling experience, the obvious answer will be to eventually introduce a checkbox in Visual Studio to enable/disable these simplified layouts. Until then, you can downgrade the target framework moniker (TFM) to net5.0
.
If you don't like it, you can file an issue in the dotnet/templating repo (or chime in on a similar issue), or even create your own templates.
Community spotlight: Marten v4 is now live
Do you know about Marten? It's a popular .NET library that allows you to use Postgresql as both a document database and a powerful event store. Jeremy Miller wrote this week about the new v4 release. Jeremy got my attention with quoting "the immortal philosopher Ferris Bueller" but also highlighted the massive changes:
- Reducing object allocations and dictionary lookups
- LINQ support improvements
- Better tracking for flexible metadata
- Event sourcing improvements
It looks to be a great release, and congrats to the team and all the great contributors. Check out the GitHub repository for more details about the project.
🌎 Last week in the .NET world
📢 Announcements
- Windows 11 has arrived.
- Mark Weitzel provides an update on the Azure REST API guidelines.
- The Azure SDK team rolls out new Azure Monitor client libraries.
- Bri Achtman writes about some ML.NET updates.
- The GitHub Advisory Database now powers
npm audit
.
đź“… Community and events
- Last week was an eventful week for the .NET Foundation. I'm not going to rehash all the events—you can read a thread on the issues, now former Executive Director Claire Novotny's apology, the comments surrounding it, and the announcement of a change in leadership. Let's hope we see structural changes, and don't unfairly scapegoat another invaluable member of the .NET community.
- Myles Borins announces a new public beta of GitHub Releases.
- DaprCon is a thing and is happening next week.
- For community standups: .NET MAUI talks about Hot Reload, EF talks about SQL Server temporal tables and EF Core 6, and ASP.NET updates us on Orchard Core.
- The Netflix Blog writes about how they safely update client applications.
- Community releases: Marten v4 is now live, Blazored Toast v3.2 is released, and Cake v1.3.0 is out.
- FluentValidation has reached 100 million downloads.
🌎 Web development
- David Walsh writes about the accent-color CSS property.
- Damien Bowden implements a secure API and a Blazor app in the same ASP.NET Core project with Azure AD authentication.
- Litan Sarker develops a web app with Angular 12, ASP.NET Core Web API, and SQL Server.
- Mike Brind writes about the Razor Pages startup experience in .NET 6.
- Scott Hanselman writes about Microsoft's guidance on ASP.NET Core diagnostic scenarios.
- David Ramel writes about Azure Functions support for .NET 6.
- Andrew Lock builds a middleware pipeline with WebApplication.
- Nwose Lotanna Victor writes about things developers do to affect web app load time.
🥅 The .NET platform
- Matthew Jones writes about DateOnly and TimeOnly in .NET 6.
- Khalid Abuhakmeh walks through EF Core ConnectionStrings.
- The Code Maze blog writes about code coverage in .NET.
- David McCarter writes about properly disposing of objects in .NET.
- Scott Hanselman writes about the differences between Hashtable, Dictionary, ConcurrentDictionary, and ImmutableDictionary.
â›… The cloud
- The Microsoft Cloud Show talks about Azure App Configuration.
- Niels Swimberghe collaborates on Power Apps using personal environments, Power Platform CLI, Git, and Azure DevOps.
- Justin Yoo writes about different ways to integrate Azure Functions auth with OpenAPI.
đź“” Languages
- Elijah Manor quickly populates a new array in JavaScript.
- Dave Brock works with file-scoped namespaces in C# 10.
- Assis Zang has 6 tips for writing elegant C# code.
- Joël Quenneville asks: who is empowered by your API design?
🏗 Design, testing, and best practices
- Peter Vogel uses JustMock to unit test legacy applications.
- Steven J. Vaughan-Nichols writes about the refresh of the OWASP Top 10.
- Dennis Martinez writes about challenges with automated end-to-end testing.
- Sam Scott and Graham Neray write about best practices for authentication and authorization for REST APIs.
- Davide Bellone offers a clean code tip.
- Sarah Drasner writes about why flow matters more than passion.
- Derek Comartin writes about his top patterns for event-driven architecture.
🎤 Podcasts and videos
- Adventures in .NET talk about pair programming and also continues the discussion on advocating for yourself.
- Jesse Liberty talks to Mads Torgersen about C# 10.
- The .NET Core Show talks to Carl-Hugo Marcotte about ASP.NET Core 5 design patterns.
- Visual Studio Toolbox discusses Solution Filters in Visual Studio.
- On .NET talks about using DynamicData.
Top comments (1)
I have to laugh when blockchain worshippers use web3 unironically since web 2.0 was also a term that never really meant anything and was only used by hucksters and con artists to sell snake oil.
Anyway, on topic, I for one don't care at all for the new templates. I am on the fence with global usings and file level statements to begin with, but I know I definitely don't want them as the default. Bring on that checkbox as soon as possible.