In the last Monday of 2021, as promised, I present you one more issue of .NET R&D Digest! This issue is a bit special because besides amazing blog posts dedicated to .NET & Windows, it also includes an amazing tale about Midori, which I personally read multiple times and every time I read it, I found something new in it («The Error Model» is my favourite).
This issue includes bits of Windows, diagnostics, story, software development, operating systems, C#, testing, COM and a bit to watch and learn about .NET.
Have a good read!
Life & Story
- A journey towards SpeakerTravel – Building a service from scratch (by Maarten Balliauw)
Having a great idea is one thing. Having it implemented is a completely different one. The journey from one to another can be long, tough and exciting. In this post Maarten Balliauw share a story of creating a SpeakerTravel service (with some interesting insights of how flight booking works).
- Blogging about Midori (by Joe Duffy)
This series by Joe Duffy is a software development tale about development of an operating system, C#, design, team management and much more. There is no way to describe this journey in a few paragraphs. The only way to understand it, is to read it. Highly recommended.
- Welcome to C# 10 (by Kathleen Dollard)
C# 10 introduced so many new features that they hardly can be described in one post and, to be honest, it is even hard to mention the most important ones. That is why reading them once again is a good thing, especially when they are described in so detailed way. In this post Kathleen Dollard goes through major features of C# 10, describing them in full details, including background and code samples.
- Accessing arrays and class fields with .NET profiling APIs (by Christophe Nasarre)
In the fifth episode Christophe Nasarre describes how you can get your debugger along with array and class parameters. Sounds simple? It is not. Seeing amount of peculiarities and how much you should know about objects internal structure just to do parameters enumeration makes new look quite differently on what Visual Studio and other IDE do. As usual, the post in easy to follow and fun to read.
- Snapshot Testing with Verify (by Dan Clarke)
Unit and integration testing helps us to identify issues. That is why it is great to have them. However, writing them (especially, when it comes to integration tests) might be quite complex and time consuming. The snapshot testing approach can significantly simplify writing these tests by removing a need to write smart assert logic. Instead, we can just compare files. In this Dan Clarke does an overview of snapshot testing approach and Verify project which implements it for .NET ecosystem. Besides the post, there is a podcast where all of these topics are discussed in more details.
- Creating an incremental generator (by Andrew Lock)
Code-generation is a powerful tool which can save you a lot of time. It could making your program faster or save you development time, just by generating things for you. So, if you have never used it in a project, then it might be a good moment to start. In this series Andrew Lock does an introduction into new, incremental source generators (introduced in .NET 6) by creating a simple, yet fully functional source generator to improve enum to string performance. Besides the generator itself, Andrew demonstrates how you can test it (using snapshot testing) and implement integration testing for you package. The posts are very detailed and contains a lot of code snippets and links to repository with complete code.
- Custom JSON serialisation with System.Text.Json converters (by Steve Gordon)
Serialisation is a never ending journey in both simplicity of support and performance. In this post Steve Gordon explores usage of built-in
System.Text.Jsonserialisation to serialise custom, polymorphic types using custom converters. As usual, the post includes code samples and detailed explanations.
- Monitoring a .NET application using OpenTelemetry (by Gérald Barré)
All apps should have monitoring capabilities, otherwise, there is no real chance to diagnose a problem anywhere except local machine. That is why platforms (like .NET) have integrated monitoring capabilities, compatible with modern standards. In this post Gérald Barré describes how you can extend your application with additional telemetry in open, and widely supported «open telemetry» format.
- Back to Basics: Add an ASP.NET Runtime Information Startup Banner (by Rick Strahl)
In .NET framework Web applications the general way of finding out what application version is running was to look at binaries or about page (just because your application was literally running inside an IIS process). However, in .NET Core our web applications are also console applications and therefore can use the same way to describe themselves. In this post Rick Strahl describes how you can easily add a startup banner to your ASP.NET Core application to display basic runtime information.
- Use YARP to host client and API server on a single origin to avoid CORS (by Niels Swimburger)
.NET expanded a lot in a last few years. Previously, it was hard to imagine that you can have a web application UI, reverse proxy and backend written completely in NET. Now it is possible. In this post Niels Swimburger demonstrates how you can host client (Blazor, Web Assembly), server (Web API) on the same host using YARP reverse proxy. The post is very detailed and includes all necessary steps to create the sample solution. Beside, it is great to see project tye here.
- Upgrading a .NET 5 “Startup-based” app to .NET 6 (by Andrew Lock)
Introduction of “Minimal API” in .NET 6 has completely changed a look of Program.cs and application startup. Does it mean we need to rewrite our .NET 5 apps? In this post Andrew Lock answers the question and describes a few approaches of how you can adopt new minimal API and web application builder in existing .NET 5 applications.
- Icon Handler with ATL (by Pavel Yosifovich)
In the era of Web it is so easy to forget about desktop application development and technologies used around it (and I am not talking about WPF or Win Forms). COM is still here, COM is still needed, and it is still used in the core of the system. In this post Pavel Yosifovich gives a very detailed walkthrough about how to extend Windows Explorer with a custom icon handler. Besides the code, the post includes a description of ATL, old but battle tested template library, which greatly simplifies development of COM components.
Watch & Learn
- .NET Conf 2021
This November, a new LTS (long term support) version of .NET was released. Meet .NET 6. Besides having a new major number, new version introduced a lot of performance improvements and platform capabilities. In this playlist from .NET Conf 2021 you will find a lot of things about new .NET and a ways it can be used.