.NET R&D Digest (March, 2024)

The first quarter of 2024 has ended. As usually, a lot of interesting things have happened – .NET Aspire got a few more features and looks like soon it will support everything. Dependency on Swashbuckle.AspNetCore is going to be removed in .NET 9 and replaced with Microsoft.AspNetCore.OpenApi package instead. A few more Microsoft projects have been open sources (Garnet, Retina). And all these are just a fraction of what is happening every second.

In all of this news storm it is so easy to lose track of new posts with interesting a valuable content unless you are subscribed to .NET R&D Digest 🙂

This issues includes bits of engineering, algorithms, software development, developers stories, C# language, tooling and a lot of .NET and .NET Internals.

Have a nice read!

Engineering

  1. Airfoil (by Bartosz Ciechanowski)
    Today, we take a lot of scientific advantages for granted. Communications, robots, cars and airplanes — all these seem so ordinary that we don’t give it an extra thought. They are just here and they just work. However, all of these things are result of a complex and beautiful engineering. In this amazing post Bartosz Ciechanowski explains how airfoil works. Inside, this post you will find numerous beautiful simulations of air flow and fluid dynamics and detailed explanations many related physical processes. Highly recommended to read.

Developers Story

  1. Bing on .NET 8: The Impact of Dynamic PGO (by Ben Watson)
    Every release of .NET is faster than a previous one because .NET teams puts a lot of effort into .NET performance and … internal adoption. A few years ago, Bing has migrated to .NET 5 and then to .NET 7. These migrations lead to significant performance improvements and now to they have migrated to .NET 8. In this post Ben Watson describes how migration to .NET 8 has significantly (once again) improved performance of Bing workflow engine. Besides an interesting information about the metrics the post unveils and interesting moment about prediction of upcoming garbage collection (see comments).

Software Development

  1. Bottleneck #06: Onboarding (by Tim Cochran and Premanand Chandrasekaran)
    A lot of things can be done by just a few people in the garage. However, no matter how these people are talented, it is inevitable that at some point in time they will need new blood with different knowledge and skills. In that moment it is critical to invest into on-boarding process to ensure new comers can integrate and have an impact as fast as possible. In this post Tim Cochran and Premanand Chandrasekaran describe why it worth investing in the on-boarding process, how you can track the success of it and what are the common issues you might encounter. The post is very details with a lot of examples.

.NET

  1. C# Language Features vs. Target Frameworks
    Figuring out mysterious `MissingMethodException` in a simple C# application (by Sergiy Teplyakov)
    Releases of C# and .NET are so close that sometimes it is so easy to forget that they are not hard bound to each other and many of the new and great C# language features are indeed available in previous versions of .NET (and even .NET Framework). However, they have to used with caution and care. In these posts Sergiy Teplyakov gives a description of how language features relate to framework version, provides a comprehensive overview of what of language features might be available in previous framework versions and demonstrates what kind of mysterious issues you might encounter if you aren’t careful enough.
  2. View your GCs statistics live with dotnet-gcstats! (by Christophe Nasarre)
    .NET Garbage Collector is a complex machinery with many moving parts sliding around. As any, modern and complex machine it provides a diagnostics interface to ensure experienced engineers are able to track down issues and monitor how it works. In this post Christophe Nasarre dives into internals of .NET GC describing some of the internal structures and events which you can use to monitor the current state of managed memory (besides, there is now a tool for this).
  3. Understanding System.Diagnostics DiagnosticSource and DiagnosticListener (by Steve Gordon)
    Writing diagnostics information is an important part of any application designed to run continuously or for an extended periods of time. In .NET there are a few ways to do it — ILogger abstraction, EventSource and DiagnosticsSource (all of these have own pros and cons and designed to fulfil slightly different scenarios). In this post Steve Gordon gives a comprehensive overview of what DiagnosticsSource is and describes how it works internally. The post is full of internals information and gives a good example of observer pattern in action 🙂
  4. An introduction to the heap data structure and .NET’s priority queue
    Behind the implementation of .NET’s PriorityQueue
    Implementing Dijkstra’s algorithm for finding the shortest path between two nodes using PriorityQueue in .NET 9 (by Andrew Lock)
    Efficient data structures are the heart of any algorithm. Modern .NET includes a wide range of collections (including a very good set of concurrent collections) which can fulfil almost any scenario. However, not all of these collections are widely known nor widely adopted. In these series (or three posts in a row) Andrew Lock gives a detailed explanation of what head data structure is, it’s implementation in .NET in form of PriorityQueue collection (with all of the internals) and demonstrates how it can be used to solve real word problems. All posts are full of details, code snippets and are easy (and interesting) to read. If by any reasons you have become interested in shortest paths problem, feel invited to read this post (by me) about implementation of Floyd-Warshall algorithm in .NET.
  5. Organizing ASP.NET Core Minimal APIs (by Tess Ferrandez)
    Minimal API was introduced in .NET 6. Since then every release of .NET includes more and more features (and .NET 8 made it a go-to solution if you are targeting Native AOT). Still, most of the samples are very simple apps with a couple of endpoints in Program.cs, which makes an impression that Minimal API is not made for «serious» applications. In this post Tess Ferrandez demonstrates how you can organise code of the Minimal API application to make it clearer, extensible and ready for “real applications”.
  6. Using Unix domain sockets with ASP.NET Core and HttpClient (by Andrew Lock)
    In a world of distributed systems, communication between services usually perceived as network communication. However, there are still plenty of scenarios when communication happens locally. In this post (which continues the topic of using HTTP and Kestrel for local communication) Andrew Lock describes how you can configure ASP.NET Core to communicate through UDS (UNIX Domain Sockets) and why you might want to do so (instead of communicating through loopback). As usual, the post is very detailed and includes multiple code samples.

Tools

  1. GummyCat – Visualize the activity of the .NET garbage collector (by Kevin Gosse)
    It is better to see once than hearing about something twice. The same saying works pretty well for visualisation of .NET garbage collection 🙂 This dotnet tool (by Kevin Gosse) visualises the layout of process memory, displaying regions and generations in a friendly, defragmentation like UI 🙂 One more tool in the box!

Tips & Tricks

  1. Generate OpenAPI specification at build time from the code in ASP.NET Core (by Gérald Barré)
    Did you know that in ASP.NET Core you can auto-generate OpenAPI specification for your API endpoint without falling back to any of the third party libraries? (I did not). In this small tip Gérald Barré describes how you can leverage a built-in packages to instrument your API with attributes to generate OpenAPI specifications.

Leave a comment