.NET R&D Digest (January, 2021)

The last weekend of January is coming, which means, it is time for the first issue of .NET R&D Digest in 2021! Don’t miss it 😊

This issues contains bits of .NET, .NET Internals, Windows, Debugging, Diagnostics and C#!

Enjoy and have a great weekend!

Windows

  1. Parent Process vs. Creator Process (by Pavel Yosifovich)
    If you have ever explored Windows process tree you might noticed the “parent” process information. Such parent-child relationship seems logical i.e. if we run an app from File Explorer then Explorer is a parent of our apps process. However, what does this relationship means on system level? Does these processes “physically” related? In this post Pavel Yosifovich explains what does parent and creator process mean; how you can get and manipulate this information.
  2. Making Win32 APIs More Accessible to More Languages
    Windows has a huge API surface. However, most of the time when you need to utilize the API you either write in C++ (by including C-style headers from Windows SDK) or handwrite some sort of PInvokes in managed languages like C#. But looks like this is not the case anymore – this post describes plans (and introduces their implementation for C#) of distributing complete Windows API metadata to enable automatic projection of Windows API definitions to any language – including an idiomatic projection to Modern C++.

.NET

  1. Applying the MVC design pattern to Razor Pages (by Andrew Lock)
    In ASP.NET Core we have MVC and Razor Pages. They are registered using different calls and to be honest they look differently – View Models + Controllers vs PageModels. But do they so different? In this post Andrew Lock demonstrates how Razor Pages use MVC design pattern. Besides the dive into framework internals Andrew also explains terminology used in both Razor Pages and MVC and lines the differences.
  2. The updated GetGCMemoryInfo API in .NET 5.0 and how it can help you (by Maoni Stephens)
    Ability to analyze application behavior is critical if you want you code to adapt to application patterns. However, such analysis isn’t possible if underlying infrastructure doesn’t provide you any information. In this post Maoni Stephens introduces an update to GetGCMemoryInfo API which was designed exactly for the aforementioned. However, as it usually happens with Maoni posts there isn’t just and small introduction – the post includes bits of history, usage examples and implementation details 🙂
  3. Using action results and content negotiation with “route-to-code” APIs (by Andrew Lock)
    ASP.NET MVC (classic and Core) is a powerful framework which implements a lot of things for us. One of these things is content negotiation (a functionality, which I personally think isn’t so popular as it should be). At the same time, we don’t always need everything from MVC but only a part of it (or at least a minimum set of features). In this post Andrew Lock describes how you can use quite “new” ASP.NET Core feature called “route to code” to implement minimalistic endpoints which utilize MVC content negotiation.
  4. Understanding “reversed” callstacks in Visual Studio and Perfview with async/await code (by Christophe Nasarre)
    async-await feature was introduced in C#5 in 2012. However, even now in 2021, you still can find something curious about the feature and tooling around it. In this post Christophe Nasarre demonstrates how (with tiny code samples), and explains why (deep dive in the async-await machinery), you can see “reversed” call stack when investigating issues in asynchronous methods.
  5. Deep Dive into Open Telemetry for .NET (by Muhammad Rehan Saeed)
    Telemetry (logs, traces and metrics) is an essential part of any application which cares about it stability and performance. In this post Muhammad Rehan Saeed describes what Open Telemetry specification is and how you can utilize its implementation in ASP.NET Core applications (It is harder that it sounds! Especially when it comes to naming differences!). This post is the first in the series so stay tuned and don’t miss the next one about Open Telemetry configuration!
  6. AccessViolation in ObjectNative::IsLockHeld (Part 1 and Part 2) (by Kevin Gosse)
    AccessViolationException in managed world of .NET is a quite rare visitor, which usually comes with a bunch of self-written unsafe code. However, this isn’t always a case and in such situation the investigation can lead you to very unexpected results. In these two posts (or maybe it would be more precise to call them a novel?) Kevin Gosse tells his story about facing the “unusual” AccessViolationException. Besides trilling plot posts contain links to related resources and demonstrate a good technic of how to dig into the issue.
  7. Snooping on .NET EventPipes (by Sebastian Solnica)
    Most of the time the need to understand internals of the application, library or framework is caused by some issue (performance or functional). However, sometimes this is just a curiosity. In this post Sebastian Solnica digs into the topic of “how dotnet diagnostics tools (using EventPipes) bind to target process” and alongside creates a diagnostics packet sniffer 🙂

Watch & Learn

  1. DRAM Anatomy Poster (by Konrad Kokosa)
    In .NET when you need to create an instance of object you simply allocate memory on “heap”. The “heap” in turn in managed by GC in form of segments. The segments are allocated (or reserved) virtual memory regions which are then mapped to physical memory by the OS. But what happens in “bare metal”? In this post Konrad Kokosa presents a new poster which explains basics of how DRAM works. In addition to beautiful poster post contains a few links which are great sources of memory knowledge.
  2. .NET GC Internals (by Konrad Kokosa)
    Writing memory friendly code is a prerequisite for good application performance in .NET. However, to write memory friendly code, we, as developers, should understand how .NET GC works. In this (still running) webinar sessions Konrad Kokosa dives deep into internals of .NET GC, explaining general concepts (upon which .NET GC is built), internal mechanics (ex. Mark phase) and how this knowledge can be applied to write memory efficient code.
  3. What do we like in C# 9? – Dotnetos webinar (by Konrad Kokosa and Szymon Kulec)
    C# 9 introduces a lot of new features. Some of these features are already well known (ex. Records) and well covered by blog posts in Internet, and some of them aren’t (ex. Native integers). In this webinar Konrad Kokosa and Szymon Kulec have selected a mix of the high and low level features and prepared a detailed introduction (with demos!) of native integers, code generators. Besides the demonstrated features Konrad and Szymon also share a lot of helpful links for future reading and existing projects.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s