.NET R&D Digest (February, 2024)

Keeping up with latest technology trends is something we, software developers, have to do constantly. Today just .NET is evolving so rapidly that it is hard to say «I have used all of the latest features» and .NET isn’t the only technology we use. However, reading everything about everything is plain impossible, this is where (at least I hope so) .NET R&D Digest can give you a hand — every month, there is a new issues filed with curated links to read and learn (and this month isn’t an exception).

This issues includes bits of hardware, software development, diagnostics, Windows, security, profiling, .NET Internals and a lot of .NET.

Enjoy!

Hardware

  1. Everything I know about SSDs (by Klaus Jensen)
    Majority of modern personal computers are equipped with SSD drives. This isn’t surprising — SSD is way faster than HDD, they are reliable, they are compact and modern versions can store terabytes of data. Cool isn’t it? But why SSD is so great? How all of these parameters are achieved and what is the real difference between SSD and HDD? If you are interested to know then in this post Klaus Jensen gives a comprehensive, high-level overview of SSD inner workings.

Software Development

  1. Bottleneck #05: Resilience and Observability (by Carl Nygard and Punit Lad)
    It is natural for applications to be perceived throughout the lens its features. In the end all users seek for a solution to a problem. However, in time, users start to expect more than just features, they start to expect applications to be available, to work swiftly and to be accessible. For a successful product it is critical not to miss this moment and start paying attention to application resiliency. In this great continuation of the Bottlenecks of Scaleups series Carl Nygard and Punit Lad give a comprehensive overview of how new products and startups fall into the trap of not paying enough attention to application resiliency and provide guidance of how this can be avoided and mitigated.
  2. Popular git config options (by Julia Evans)
    Nowadays git is probably the most wide spread source control system. This is due to many reasons but one of them is definitely its configurability. In this post Julia Evans describes a set of popular git options you can set to improve your git experience. The post provides a short and simple description to every mentioned command and includes a few interesting links to follow (especially, about zdiff3 and diff modes).
  3. .NET Continuous Profiler: CPU and Wall Time Profiling (by Christophe Nasarre)
    Every application has multiple metrics (aside from business) which can be monitored continuously. One of such metrics is CPU consumption. In the second post of the series, Christophe Nasarre describes how CPU consumption metrics can be measured by a continuous profiler with minimal impact on application performance.

.NET

  1. Understanding C# 8 default interface methods
    Using default interface methods for performance gains in IHeaderDictionary (by Andrew Lock)
    C# is an object-oriented language, which means it support inheritance and polymorphism (and encapsulation of course). In a sense of these, C# prohibits multiple inheritance and relies on the interfaces when excessive polymorphism is required. However, in C# 8 the language team introduced one of the most controversial features — default interface methods, giving the later an ability to carry implementation. In these two posts Andrew Lock describes (in a great details) what default interface methods are, where they can be used to do good and what can go wrong if you don’t understand all of the above.
  2. 8 ways to set the URLs for an ASP.NET Core app (by Andrew Lock)
    ASP.NET Core has a multi-layer, extensible configuration system. It takes almost nothing to start with the defaults but if you need more control — you can get it (usually, in multiple ways). In this post Andrew Lock demonstrates 8 (eight!) different ways of how you can configure application URLs depending on what exactly you need.
  3. Dumping the managed heap in C# (by Kevin Gosse)
    One of the things interfaces are good for is to define the behaviour instead of implementation. This gives confidence to a consumer and freedom to the implementer. However, what if you want to find something that is not freely exposed? Can you do so? In this post, Kevin Gosse demonstrates how you can use knowledge of .NET GC internal structures (which you can find on GitHub) to walk down every object in a managed heap, effectively replicating dumpheap -stat command. The post is very detailed and represents a great piece of knowledge of .NET internals.
  4. Using named pipes with ASP.NET Core and HttpClient (by Andrew Lock)
    ASP.NET Core is well known for its extensibility (just look at the previous post with 8 ways to set a URL) — you can tweak almost any part of it in a multiple ways. Still, sometimes I am surprised by how much of it you can change. In this post Andrew Lock describes how you can use named pipes (on both Windows and Linux) to send and receive HTTP requests. As usual, the post is very detailed and includes thoughtful explanations and code samples.
  5. Improving ASP.NET Core Security By Putting Your Cookies On A Diet (by Tore Nestenius)
    Implementing application sing-in and sign-out functionality is a non trivial task (as everything related to security). It depends on the selected schema, on the requirements and on the platform. In ASP.NET Core, the default approach is to use cookie based authentication and store all of the required information in it (encrypted of course). In this post Tore Nestenius describes downsides of having all authentication information in the cookie and demonstrating how you can split session information from authentication and what benefits such separation provides.

Windows

  1. Projected File System (by Pavel Yosifovich)
    Since the begining, Windows has a big number of API to access and manipulate files (local, network and in memory). It turns out that in modern versions, you can represent your own data as files and use the same API to access it (or even integrate it into Windows Explorer). In this post Pavel Yosifovich describes what ProjFS is, and demonstrates how you can write a plugin to show System Objects in Windows Explorer. The post is very detailed and includes a link to a complete sample.

Tips & Tricks

  1. Checking if a collection is empty in C# (by Gérald Barré)
    How hard is to check that a collection has no elements in C#? Sounds like a silly question but if you think of it more thoughtfully — is there a unified way to check if collection is empty? Well, if you like me, then this tip will be a nice surprise because there is. In this small tip Gérald Barré describes how you can check if a collection is empty and demonstrates how pattern matching can solve it in a unified fashion.
  2. Getting all exceptions thrown from Parallel.ForEachAsync (by Gérald Barré)
    In C#, asynchronous code in most cases looks exactly the same as synchronous one (thanks to async-await). However, we still should not forget that there might be multiple threads involved. In this short tip Gérald Barré demonstrates how you can catch all exceptions thrown from ParallelAsync method.
  3. Creating an HttpClient that uses DNS over Https (by Gérald Barré)
    Applications rely on the underlying operating system in many ways. Besides obvious dependency on the API they also consume a lot of configuration (for instance, language and region settings). However, sometimes we might need to ignore OS settings and do it our way. In this small tip Gérald Barré demonstrates how you can configure HttpClient to use own DNS configuration instead of using information provided by operating system. 

Leave a comment