Understanding High CPU and Memory Usage: When to Act and When to Relax

Modern applications, especially cloud applications running on right-sized infrastructure, rely heavily on efficient resource management, but “efficiency” doesn’t always mean “low usage.” High CPU or memory consumption can be either a red flag or a sign of optimal performance, depending on the context. In this post, we’ll explore when to celebrate high resource usage—and when to panic—with a focus on .NET applications.

Continue reading “Understanding High CPU and Memory Usage: When to Act and When to Relax”

Future-proofing Result<T> Libraries

C# is coming ‘soon’ with Type Unions (see the official proposal and Nick’s video on this), which I think is great. However it’s not there yet and if you need it now it’s important t consider which library will require the least refactoring when this feature becomes part of the official language specification.

This post explores some of the most popular libraries in .NET for implementing this pattern and helps you decide which one fits your project’s needs.

Continue reading “Future-proofing Result<T> Libraries”

Exploring options for building REST APIs with C# and deploying to Azure

Somebody asked me, what is the difference between a C# REST API running as a Web App on an App Service as a container and a C# REST API running as a HTTP Function on an App Service or a Consumption Plan?

There are lots of aspects in this question, so let’s unpack this a bit first.

First, let’s talk about the various ways we can build REST APIs in .NET.
Then, we’ll talk about how you can deploy these, either as code or as a container.
Last, we’ll explore – if you end up with a container – which Azure service best fits your needs.

Continue reading “Exploring options for building REST APIs with C# and deploying to Azure”

Records and Interfaces: Here Be Dragons

When it comes to C# types—classes, structs, and records—understanding the difference between value and reference equality is crucial. Each type behaves differently in terms of equality checks, inheritance, and how they manage their internal state. However, things can get tricky when you introduce interfaces into the mix, particularly when dealing with records.

Continue reading “Records and Interfaces: Here Be Dragons”

Optimal usage of Global Usings

I have a solution with ~40 projects, built during many years with wild usings that I wanted to clean up. The global usings feature, introduced in with C# 10.0 and .NET 6 (nov21) to simplify and reduce the repetition of commonly used namespaces throughout a project.

The question I have is, how do I ‘get’ the most commonly used namespaces and how do I do that at scale.

Continue reading “Optimal usage of Global Usings”