# Andrew Lock | .NET Escapades

Hi, my name is Andrew, or 'Sock' to most people. This blog is where I share my experiences as I journey into ASP.NET Core.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Understanding Lazy thread safety modes

DevFeed: [Understanding Lazy thread safety modes](<https://devfeed.tech/articles/understanding-lazy-thread-safety-modes-116292.md>)

Original publisher: [Read original article](<https://andrewlock.net/understanding-lazy-thread-safety-modes/>)

Author: Andrew Lock

Published: 2026-11-03T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [thread safe data sharing](<https://devfeed.tech/topics/thread-safe-data-sharing.md>), [Exception](<https://devfeed.tech/topics/exception.md>), [locking](<https://devfeed.tech/topics/locking.md>)

Tags: [caching](<https://devfeed.tech/tags/caching.md>), [concurrency](<https://devfeed.tech/tags/concurrency.md>), [concurrent](<https://devfeed.tech/tags/concurrent.md>), [exceptions](<https://devfeed.tech/tags/exceptions.md>), [lazy](<https://devfeed.tech/tags/lazy.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [thread](<https://devfeed.tech/tags/thread.md>), [thread-safety](<https://devfeed.tech/tags/thread-safety.md>)

### AI overview

`Lazy<T>` defers factory execution until `Value` is accessed. `None` is for single-threaded use and caches factory exceptions; concurrent access is unsafe. `PublicationOnly` lets concurrent callers run the factory independently, publishes the first successful result for everyone, and does not cache exceptions--each factory call that throws still reports its own exception. `ExecutionAndPublication` runs the factory once while other callers wait, and caches any exception, so later accesses keep throwing it. The article says `ExecutionAndPublication` avoids duplicate work and allocations, while `PublicationOnly` may be faster when initialization is cheap, safe to repeat, and lock contention is significant. `LazyInitializer.EnsureInitialized` offers similar publication behaviors without a `Lazy<T>` allocation and does not cache exceptions. A proposed `cacheExceptions` option was approved but was not yet implemented in the described account.

### Source excerpt

In this post I look at how the different `LazyThreadSafetyMode` values work with `Lazy`, and how exceptions are handled for each mode

## An introduction to Compact Binary Object Representation (CBOR) in .NET

DevFeed: [An introduction to Compact Binary Object Representation (CBOR) in .NET](<https://devfeed.tech/articles/an-introduction-to-compact-binary-object-representation-cbor-in-net-90927.md>)

Original publisher: [Read original article](<https://andrewlock.net/an-introduction-to-compact-binary-object-notation-in-dotnet/>)

Author: Andrew Lock

Published: 2026-10-20T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Data serialization](<https://devfeed.tech/topics/data-serialization.md>), [.NET](<https://devfeed.tech/topics/net.md>), [Decoding](<https://devfeed.tech/topics/decoding.md>), [JSON](<https://devfeed.tech/topics/json.md>), [Encoding](<https://devfeed.tech/topics/encoding.md>), [hex value](<https://devfeed.tech/topics/hex-value.md>), [NuGet](<https://devfeed.tech/topics/nuget.md>), [system.text.json](<https://devfeed.tech/topics/system-text-json.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [apis](<https://devfeed.tech/tags/apis.md>), [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [base64](<https://devfeed.tech/tags/base64.md>), [data-protection](<https://devfeed.tech/tags/data-protection.md>), [data-serialization](<https://devfeed.tech/tags/data-serialization.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [json](<https://devfeed.tech/tags/json.md>), [net](<https://devfeed.tech/tags/net.md>), [net-10](<https://devfeed.tech/tags/net-10.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [net-framework](<https://devfeed.tech/tags/net-framework.md>), [nuget](<https://devfeed.tech/tags/nuget.md>), [nuget-package](<https://devfeed.tech/tags/nuget-package.md>)

### AI overview

CBOR offers a self-describing binary alternative to JSON, with native binary data, compact encodings for values such as small numbers, and support for indefinite-length collections that can help with streaming. Text payload sizes are roughly comparable to JSON, and actual savings depend on the data. The excerpt contrasts CBOR with Protobuf, which can be highly efficient but requires shared schemas, and MessagePack, which is similar but lacks CBOR's formal IETF standardization and streaming support as described here. In .NET, System.Formats.Cbor provides low-level CborWriter and CborReader APIs: callers write and read primitive values and manage structure themselves rather than automatically mapping objects. The examples cover encoding and decoding maps and arrays, selecting conformance modes such as canonical key ordering, and skipping unknown values for forward compatibility. The author suggests JSON remains suitable for most APIs and points to ASP.NET Core's use of CBOR for compact, application-specific cookie data.

### Source excerpt

In this post I introduce CBOR as a JSON alternative, and show how to use the System.Formats.Cbor NuGet package to read and write CBOR encoded data

## Stripping extra dependencies in .NET NativeAOT apps using linker substitutions

DevFeed: [Stripping extra dependencies in .NET NativeAOT apps using linker substitutions](<https://devfeed.tech/articles/stripping-extra-dependencies-in-net-nativeaot-apps-using-linker-substitutions-65543.md>)

Original publisher: [Read original article](<https://andrewlock.net/stripping-extra-dependencies-in-.net-nativeaot-apps-using-linker-substitutions/>)

Author: Andrew Lock

Published: 2026-10-06T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [native aot](<https://devfeed.tech/topics/native-aot.md>), [trimming](<https://devfeed.tech/topics/trimming.md>), [toolchain](<https://devfeed.tech/topics/toolchain.md>), [.NET](<https://devfeed.tech/topics/net.md>), [linker](<https://devfeed.tech/topics/linker.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [azure](<https://devfeed.tech/tags/azure.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [core](<https://devfeed.tech/tags/core.md>), [dependencies](<https://devfeed.tech/tags/dependencies.md>), [dotnet](<https://devfeed.tech/tags/dotnet.md>), [guide](<https://devfeed.tech/tags/guide.md>), [linker](<https://devfeed.tech/tags/linker.md>), [nativeaot](<https://devfeed.tech/tags/nativeaot.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [net-core-observability](<https://devfeed.tech/tags/net-core-observability.md>), [net-sdk](<https://devfeed.tech/tags/net-sdk.md>), [observability](<https://devfeed.tech/tags/observability.md>)

### AI overview

The article explains how linker substitutions in a .NET NativeAOT application can replace a runtime property check with a compile-time constant, allowing additional dead-code elimination and removal of unused dependencies. In the described case, the change reduced the binary size by 22-25%.

### Source excerpt

In this post I describe how to perform method-substitutions with the NativeAOT linker to remove additional dependencies that the linker couldn't see were unused

## Experimental support for Device Bound Session Credentials (DBSC) in ASP.NET Core: Exploring the .NET 11 preview - Part 8

DevFeed: [Experimental support for Device Bound Session Credentials (DBSC) in ASP.NET Core: Exploring the .NET 11 preview - Part 8](<https://devfeed.tech/articles/experimental-support-for-device-bound-session-credentials-dbsc-in-asp-net-core-exploring-the-net-11-preview-part-8-57969.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-8-experimental-support-for-device-bound-session-credentials-in-aspnetcore/>)

Author: Andrew Lock

Published: 2026-09-22T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [ASP.NET Core](<https://devfeed.tech/topics/asp-net-core.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [.NET](<https://devfeed.tech/topics/net.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Cookies](<https://devfeed.tech/topics/cookies.md>), [private key](<https://devfeed.tech/topics/private-key.md>), [public key](<https://devfeed.tech/topics/public-key.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [Server](<https://devfeed.tech/topics/server.md>)

Tags: [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [browser](<https://devfeed.tech/tags/browser.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [cookies](<https://devfeed.tech/tags/cookies.md>), [http](<https://devfeed.tech/tags/http.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp-asp-net-core-security](<https://devfeed.tech/tags/net-11-c-sharp-asp-net-core-security.md>), [private-key](<https://devfeed.tech/tags/private-key.md>), [public-key](<https://devfeed.tech/tags/public-key.md>), [security](<https://devfeed.tech/tags/security.md>)

### AI overview

This tutorial explores experimental Device Bound Session Credentials support in .NET 11 through the Microsoft.AspNetCore.Authentication.DeviceBoundSessions package. It explains how to use DBSC with an ASP.NET Core Identity application and describes its request flow and implementation details.

### Source excerpt

In this post I look at the new experimental support for DBSC provided by the Microsoft.AspNetCore.Authentication.DeviceBoundSessions package

## Understanding Device Bound Session Credentials (DBSC)

DevFeed: [Understanding Device Bound Session Credentials (DBSC)](<https://devfeed.tech/articles/understanding-device-bound-session-credentials-dbsc-51489.md>)

Original publisher: [Read original article](<https://andrewlock.net/understanding-device-bound-session-credentials/>)

Author: Andrew Lock

Published: 2026-09-15T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Authentication](<https://devfeed.tech/topics/authentication.md>), [Protocol (disambiguation)](<https://devfeed.tech/topics/protocol.md>), [Cookies](<https://devfeed.tech/topics/cookies.md>), [Web app](<https://devfeed.tech/topics/webapp.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Server](<https://devfeed.tech/topics/server.md>), [Vulnerabilities](<https://devfeed.tech/topics/vulnerabilities.md>), [private key](<https://devfeed.tech/topics/private-key.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [browser](<https://devfeed.tech/tags/browser.md>), [cookies](<https://devfeed.tech/tags/cookies.md>), [credentials](<https://devfeed.tech/tags/credentials.md>), [private-key](<https://devfeed.tech/tags/private-key.md>), [protocol](<https://devfeed.tech/tags/protocol.md>), [security](<https://devfeed.tech/tags/security.md>), [server](<https://devfeed.tech/tags/server.md>), [vulnerabilities](<https://devfeed.tech/tags/vulnerabilities.md>), [web-applications](<https://devfeed.tech/tags/web-applications.md>)

### AI overview

An introduction to Device Bound Session Credentials (DBSC), a protocol designed to reduce session hijacking by binding authentication cookies to the device where they were issued. The post explains the security problem, the browser and server verification flow, and DBSC's progressive-enhancement approach.

### Source excerpt

In this post I provide an introduction to Device Bound Session Credentials, I look at how DBSC protects against session hijacking, and how the protocol works

## The pain of serializing unions and closed class hierarchies with System.Text.Json: Exploring the .NET 11 preview - Part 7

DevFeed: [The pain of serializing unions and closed class hierarchies with System.Text.Json: Exploring the .NET 11 preview - Part 7](<https://devfeed.tech/articles/the-pain-of-serializing-unions-and-closed-class-hierarchies-with-system-text-json-exploring-the-net-11-preview-part-7-51479.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-7-the-pain-of-serializing-unions-and-closed-class-hierarchies-with-system-text-json/>)

Author: Andrew Lock

Published: 2026-09-01T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [system.text.json](<https://devfeed.tech/topics/system-text-json.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [Closed hierarchies](<https://devfeed.tech/topics/closed-hierarchies.md>), [JSON](<https://devfeed.tech/topics/json.md>), [union types](<https://devfeed.tech/topics/union-types.md>), [Programming](<https://devfeed.tech/topics/programming.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [c-sharp-15](<https://devfeed.tech/tags/c-sharp-15.md>), [closed-hierarchies](<https://devfeed.tech/tags/closed-hierarchies.md>), [json](<https://devfeed.tech/tags/json.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp](<https://devfeed.tech/tags/net-11-c-sharp.md>), [net-11-preview-7](<https://devfeed.tech/tags/net-11-preview-7.md>), [preview](<https://devfeed.tech/tags/preview.md>), [rust](<https://devfeed.tech/tags/rust.md>), [system-text-json](<https://devfeed.tech/tags/system-text-json.md>)

### AI overview

This tutorial examines how System.Text.Json handles union types and closed class hierarchies introduced in .NET 11 and C# 15. It compares the two approaches, demonstrates serialization and deserialization, and documents errors and compatibility edge cases encountered in .NET 11 Preview 7.

### Source excerpt

In this post I discuss the System.Text.Json support for unions and closed hierarchies coming in .NET 11, the decisions made, and some of the sharp edges I hit

## Finding the total number of processors on a machine with .NET

DevFeed: [Finding the total number of processors on a machine with .NET](<https://devfeed.tech/articles/finding-the-total-number-of-processors-on-a-machine-with-net-51480.md>)

Original publisher: [Read original article](<https://andrewlock.net/finding-the-total-number-of-processors-on-a-machine-with-dotnet/>)

Author: Andrew Lock

Published: 2026-08-25T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [cpu](<https://devfeed.tech/topics/cpu.md>), [.NET Framework](<https://devfeed.tech/topics/net-framework.md>)

Tags: [2](<https://devfeed.tech/tags/2.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [linux](<https://devfeed.tech/tags/linux.md>), [macos](<https://devfeed.tech/tags/macos.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [net-core-observability](<https://devfeed.tech/tags/net-core-observability.md>), [net-framework](<https://devfeed.tech/tags/net-framework.md>), [observability](<https://devfeed.tech/tags/observability.md>)

### AI overview

This post explains how to retrieve the total number of logical processors on a host machine in .NET, rather than only the processors available to the current process. It compares behavior across .NET Framework and modern .NET, then describes using native APIs on Windows and macOS and parsing files on Linux.

### Source excerpt

In this post I show how to find the total number of logical CPUs on a host (not just those available to a process); something that isn't exposed in modern .NET

## Automatic CSRF protection based on Fetch Metadata headers: Exploring the .NET 11 preview - Part 6

DevFeed: [Automatic CSRF protection based on Fetch Metadata headers: Exploring the .NET 11 preview - Part 6](<https://devfeed.tech/articles/automatic-csrf-protection-based-on-fetch-metadata-headers-exploring-the-net-11-preview-part-6-51478.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-6-automatic-csrf-protection-based-on-fetch-metadata-http-headers/>)

Author: Andrew Lock

Published: 2026-08-04T09:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [ASP.NET Core](<https://devfeed.tech/topics/asp-net-core.md>), [.NET](<https://devfeed.tech/topics/net.md>), [Protection](<https://devfeed.tech/topics/protection.md>), [fetch](<https://devfeed.tech/topics/fetch.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Cookies](<https://devfeed.tech/topics/cookies.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>)

Tags: [account](<https://devfeed.tech/tags/account.md>), [asp-net](<https://devfeed.tech/tags/asp-net.md>), [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [asp-net-core-security-csrf-cors](<https://devfeed.tech/tags/asp-net-core-security-csrf-cors.md>), [browser](<https://devfeed.tech/tags/browser.md>), [cookies](<https://devfeed.tech/tags/cookies.md>), [cors](<https://devfeed.tech/tags/cors.md>), [csrf](<https://devfeed.tech/tags/csrf.md>), [fetch](<https://devfeed.tech/tags/fetch.md>), [headers](<https://devfeed.tech/tags/headers.md>), [http](<https://devfeed.tech/tags/http.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [protection](<https://devfeed.tech/tags/protection.md>), [security](<https://devfeed.tech/tags/security.md>)

### AI overview

A technical walkthrough of the CSRF protection added to ASP.NET Core in .NET 11 Preview 6. The feature uses Fetch Metadata HTTP headers instead of traditional antiforgery tokens, and the post explains its implementation and limitations for MVC and Razor Pages.

### Source excerpt

In this post I describe the new Cross-Site Request Forgery protection added to ASP.NET Core that uses Fetch Metadata HTTP headers instead of antiforgery tokens

## Understanding the Fetch Metadata HTTP headers: Sec-Fetch-Site and friends

DevFeed: [Understanding the Fetch Metadata HTTP headers: Sec-Fetch-Site and friends](<https://devfeed.tech/articles/understanding-the-fetch-metadata-http-headers-sec-fetch-site-and-friends-51490.md>)

Original publisher: [Read original article](<https://andrewlock.net/understanding-the-fetch-metadata-http-headers-sec-fetch-site-and-friends/>)

Author: Andrew Lock

Published: 2026-07-29T09:50:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [fetch](<https://devfeed.tech/topics/fetch.md>), [HTTP](<https://devfeed.tech/topics/http.md>), [Security](<https://devfeed.tech/topics/security.md>), [browser](<https://devfeed.tech/topics/browser.md>), [Web Development](<https://devfeed.tech/topics/web-development.md>)

Tags: [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [asp-net-core-security-csrf-cors](<https://devfeed.tech/tags/asp-net-core-security-csrf-cors.md>), [browser](<https://devfeed.tech/tags/browser.md>), [cors](<https://devfeed.tech/tags/cors.md>), [csrf](<https://devfeed.tech/tags/csrf.md>), [fetch](<https://devfeed.tech/tags/fetch.md>), [headers](<https://devfeed.tech/tags/headers.md>), [http](<https://devfeed.tech/tags/http.md>), [security](<https://devfeed.tech/tags/security.md>)

### AI overview

This tutorial explains Fetch Metadata HTTP request headers, including the context they provide to servers about browser requests. It covers when the headers are sent, their possible values, and how servers can use them to understand request provenance and intent.

### Source excerpt

In this post I describe the Fetch Metadata HTTP headers like Sec-Fetch-Site and Sec-Fetch-Mode which give information to a server about the context of a request

## Improvements to Reading Process Output in .NET 11 Preview 5

DevFeed: [Improvements to Reading Process Output in .NET 11 Preview 5](<https://devfeed.tech/articles/improvements-to-reading-process-outputs-exploring-the-net-11-preview-part-5-51477.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-5-improvments-to-process-apis/>)

Author: Andrew Lock

Published: 2026-07-07T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [Process](<https://devfeed.tech/topics/process.md>), [Deadlock](<https://devfeed.tech/topics/deadlock.md>), [Concurrency](<https://devfeed.tech/topics/concurrency.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [deadlock](<https://devfeed.tech/tags/deadlock.md>), [improvements](<https://devfeed.tech/tags/improvements.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp](<https://devfeed.tech/tags/net-11-c-sharp.md>), [preview](<https://devfeed.tech/tags/preview.md>), [process](<https://devfeed.tech/tags/process.md>)

### AI overview

This post examines .NET 11 improvements to the Process APIs, focusing on running processes and reading standard output and error without deadlocks. It compares the behavior in .NET 10 with the newer APIs and explains how parallel pipe draining avoids blocking.

### Source excerpt

In this post I show some of the improvements to the Process API in .NET 11 for running processes and reading their outputs without risk of deadlock

## Closed class hierarchies: Exploring the .NET 11 preview - Part 4

DevFeed: [Closed class hierarchies: Exploring the .NET 11 preview - Part 4](<https://devfeed.tech/articles/closed-class-hierarchies-exploring-the-net-11-preview-part-4-51476.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-4-closed-class-hierarchies/>)

Author: Andrew Lock

Published: 2026-06-30T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [class](<https://devfeed.tech/topics/class.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [class](<https://devfeed.tech/tags/class.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [hierarchy](<https://devfeed.tech/tags/hierarchy.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp](<https://devfeed.tech/tags/net-11-c-sharp.md>), [preview](<https://devfeed.tech/tags/preview.md>)

### AI overview

This post explains closed class hierarchies in .NET 11 preview, including how they restrict inheritance to a single assembly and enable the compiler to perform exhaustiveness checking.

### Source excerpt

In this post I describe what a close closed hierarchy is, how to create one, and discuss why you might want to

## Avoiding ToString() allocations with StringBuilder.MoveChunks: Exploring the .NET 11 preview - Part 3

DevFeed: [Avoiding ToString() allocations with StringBuilder.MoveChunks: Exploring the .NET 11 preview - Part 3](<https://devfeed.tech/articles/avoiding-tostring-allocations-with-stringbuilder-movechunks-exploring-the-net-11-preview-part-3-51475.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-3-avoiding-tostring-allocations-with-stringbuilder-movechunks/>)

Author: Andrew Lock

Published: 2026-06-23T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [API](<https://devfeed.tech/topics/api.md>), [software-development](<https://devfeed.tech/topics/software-development.md>), [implementation](<https://devfeed.tech/topics/implementation.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [development](<https://devfeed.tech/tags/development.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp](<https://devfeed.tech/tags/net-11-c-sharp.md>)

### AI overview

This article examines the .NET 11 preview MoveChunks API for StringBuilder. It explains how the API moves accumulated chunks into a new instance, resets the original, and can reduce allocations compared with ordinary string conversion or copying.

### Source excerpt

In this post I take a short look at the new MoveChunks API, explore how it works, what it's for, and how the new API provides opportunities for public APIs

## .NET (OK, C#) finally gets union types🎉: Exploring the .NET 11 preview - Part 2

DevFeed: [.NET (OK, C#) finally gets union types🎉: Exploring the .NET 11 preview - Part 2](<https://devfeed.tech/articles/net-ok-c-finally-gets-union-types-exploring-the-net-11-preview-part-2-51474.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-2-dotnet-gets-union-types/>)

Author: Andrew Lock

Published: 2026-05-19T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [union types](<https://devfeed.tech/topics/union-types.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Functional programming](<https://devfeed.tech/topics/functional-programming.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [c-sharp-15](<https://devfeed.tech/tags/c-sharp-15.md>), [functional-programming](<https://devfeed.tech/tags/functional-programming.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-c-sharp](<https://devfeed.tech/tags/net-11-c-sharp.md>), [preview](<https://devfeed.tech/tags/preview.md>), [programming](<https://devfeed.tech/tags/programming.md>), [types](<https://devfeed.tech/tags/types.md>), [union-types](<https://devfeed.tech/tags/union-types.md>)

### AI overview

The post examines union types in C# 15 and .NET 11 preview, covering their purpose, implementation, usage, and custom type creation. It also explains how unions can represent values from several potentially unrelated types and relates them to the result pattern.

### Source excerpt

In this post I discuss the support for union types released in .NET 11, how they're implemented, the choices made, and how to create your own

## Running background tasks in Blazor with Web Workers: Exploring the .NET 11 preview - Part 1

DevFeed: [Running background tasks in Blazor with Web Workers: Exploring the .NET 11 preview - Part 1](<https://devfeed.tech/articles/running-background-tasks-in-blazor-with-web-workers-exploring-the-net-11-preview-part-1-51473.md>)

Original publisher: [Read original article](<https://andrewlock.net/exploring-the-dotnet-11-preview-1-running-background-tasks-in-blazor-with-web-workers/>)

Author: Andrew Lock

Published: 2026-05-12T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Blazor](<https://devfeed.tech/topics/blazor.md>), [.NET](<https://devfeed.tech/topics/net.md>), [WebAssembly](<https://devfeed.tech/topics/web-assembly.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Windows](<https://devfeed.tech/topics/windows.md>)

Tags: [background](<https://devfeed.tech/tags/background.md>), [blazor](<https://devfeed.tech/tags/blazor.md>), [cpu](<https://devfeed.tech/tags/cpu.md>), [net](<https://devfeed.tech/tags/net.md>), [net-11](<https://devfeed.tech/tags/net-11.md>), [net-11-blazor](<https://devfeed.tech/tags/net-11-blazor.md>), [preview](<https://devfeed.tech/tags/preview.md>), [web](<https://devfeed.tech/tags/web.md>)

### AI overview

A tutorial on the .NET 11 Web Worker project template for Blazor applications. It explains how Web Workers run CPU-intensive tasks on background threads so the browser UI remains responsive, and describes the template's purpose and implementation context.

### Source excerpt

In this post I discuss the new Web Worker template available in .NET 11 for running CPU intensive tasks without blocking the UI

## New features in Git 2.54: easier rebasing, hooks, and statistics

DevFeed: [New features in Git 2.54: easier rebasing, hooks, and statistics](<https://devfeed.tech/articles/new-features-in-git-2-54-easier-rebasing-hooks-and-statistics-51482.md>)

Original publisher: [Read original article](<https://andrewlock.net/new-features-in-git-2-54-easier-rebasing-hooks-and-statistcs/>)

Author: Andrew Lock

Published: 2026-04-28T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Git](<https://devfeed.tech/topics/git.md>), [hooks](<https://devfeed.tech/topics/hooks.md>), [Repository](<https://devfeed.tech/topics/repository.md>), [structure](<https://devfeed.tech/topics/structure.md>), [ide](<https://devfeed.tech/topics/ide.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [c-sharp-performance](<https://devfeed.tech/tags/c-sharp-performance.md>), [config](<https://devfeed.tech/tags/config.md>), [git](<https://devfeed.tech/tags/git.md>), [hooks](<https://devfeed.tech/tags/hooks.md>), [new-features](<https://devfeed.tech/tags/new-features.md>), [performance](<https://devfeed.tech/tags/performance.md>), [statistics](<https://devfeed.tech/tags/statistics.md>)

### AI overview

A post covering selected new features in Git 2.54, including simpler rebasing commands, hooks defined in configuration, and statistics about Git repositories.

### Source excerpt

In this post I show some of the new features in Git 2.54 including simple rebases with git history, config-based hooks, and stats with git repo structure

## Removing byte\[\] allocations in .NET Framework using ReadOnlySpan

DevFeed: [Removing byte\[\] allocations in .NET Framework using ReadOnlySpan](<https://devfeed.tech/articles/removing-byte-allocations-in-net-framework-using-readonlyspan-51484.md>)

Original publisher: [Read original article](<https://andrewlock.net/removingbyte-array-allocations-in-dotnet-framework-using-readonlyspan-t/>)

Author: Andrew Lock

Published: 2026-04-21T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [.NET Framework](<https://devfeed.tech/topics/net-framework.md>), [C#](<https://devfeed.tech/topics/csharp.md>), [Code](<https://devfeed.tech/topics/code.md>), [Compiler](<https://devfeed.tech/topics/compiler.md>)

Tags: [c-sharp](<https://devfeed.tech/tags/c-sharp.md>), [c-sharp-performance](<https://devfeed.tech/tags/c-sharp-performance.md>), [code](<https://devfeed.tech/tags/code.md>), [compiler](<https://devfeed.tech/tags/compiler.md>), [memory](<https://devfeed.tech/tags/memory.md>), [net](<https://devfeed.tech/tags/net.md>), [net-framework](<https://devfeed.tech/tags/net-framework.md>), [optimizations](<https://devfeed.tech/tags/optimizations.md>), [performance](<https://devfeed.tech/tags/performance.md>)

### AI overview

This post explains how to reduce byte-array and other memory allocations in C# applications targeting .NET, including .NET Framework. It covers using Span and ReadOnlySpan, compiler-generated optimizations, changes to the generated IL, and relevant caveats.

### Source excerpt

In this post I describe how to remove static byte[] allocations, even on .NET Framework, by using Span, look at the associated IL, and discuss the risks

## Running AI agents with customized templates using docker sandbox

DevFeed: [Running AI agents with customized templates using docker sandbox](<https://devfeed.tech/articles/running-ai-agents-with-customized-templates-using-docker-sandbox-51486.md>)

Original publisher: [Read original article](<https://andrewlock.net/running-ai-agents-with-customized-templates-in-docker-sandbox/>)

Author: Andrew Lock

Published: 2026-04-14T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Docker Sandboxes](<https://devfeed.tech/topics/docker-sandboxes.md>), [Docker](<https://devfeed.tech/topics/docker.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [Developer Tools](<https://devfeed.tech/topics/developer-tools.md>)

Tags: [agents](<https://devfeed.tech/tags/agents.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-agents](<https://devfeed.tech/tags/ai-agents.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [dev-tools](<https://devfeed.tech/tags/dev-tools.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-sandboxes](<https://devfeed.tech/tags/docker-sandboxes.md>), [getting-started](<https://devfeed.tech/tags/getting-started.md>), [getting-started-ai-docker-installation](<https://devfeed.tech/tags/getting-started-ai-docker-installation.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [installation](<https://devfeed.tech/tags/installation.md>), [sandbox](<https://devfeed.tech/tags/sandbox.md>), [templates](<https://devfeed.tech/tags/templates.md>)

### AI overview

A tutorial on creating custom Docker Sandbox templates that include additional development tools, including variants based on different Docker images. It uses Claude Code examples and notes a possible issue with .NET builds in sandboxed personal projects.

### Source excerpt

In this post I describe how to create custom templates for Docker Sandboxes, so that your sandboxes start with additional tools immediately available

## Running AI agents safely in a microVM using docker sandbox

DevFeed: [Running AI agents safely in a microVM using docker sandbox](<https://devfeed.tech/articles/running-ai-agents-safely-in-a-microvm-using-docker-sandbox-51485.md>)

Original publisher: [Read original article](<https://andrewlock.net/running-ai-agents-safely-in-a-microvm-using-docker-sandbox/>)

Author: Andrew Lock

Published: 2026-04-07T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [Docker Sandboxes](<https://devfeed.tech/topics/docker-sandboxes.md>), [AI-assisted coding](<https://devfeed.tech/topics/ai-assisted-coding.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [permission](<https://devfeed.tech/topics/permission.md>)

Tags: [agents](<https://devfeed.tech/tags/agents.md>), [ai](<https://devfeed.tech/tags/ai.md>), [ai-coding](<https://devfeed.tech/tags/ai-coding.md>), [ai-coding-agents](<https://devfeed.tech/tags/ai-coding-agents.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [coding-agents](<https://devfeed.tech/tags/coding-agents.md>), [docker](<https://devfeed.tech/tags/docker.md>), [docker-sandboxes](<https://devfeed.tech/tags/docker-sandboxes.md>), [getting-started](<https://devfeed.tech/tags/getting-started.md>), [getting-started-ai-docker-installation](<https://devfeed.tech/tags/getting-started-ai-docker-installation.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [installation](<https://devfeed.tech/tags/installation.md>), [permissions](<https://devfeed.tech/tags/permissions.md>), [sandbox](<https://devfeed.tech/tags/sandbox.md>)

### AI overview

A tutorial on running AI coding agents, particularly Claude Code, in Docker Sandboxes to make bypass-permissions or "YOLO" modes safer through microVM isolation. It explains the productivity problems caused by repeated tool-call permission prompts and the risks of allowing an agent unrestricted access.

### Source excerpt

In this post I show how to run AI coding agents safely while still using YOLO/dangerous mode using docker sandboxes and the sbx tool

## Configuring contextual options with Microsoft.Extensions.Options.Contextual

DevFeed: [Configuring contextual options with Microsoft.Extensions.Options.Contextual](<https://devfeed.tech/articles/configuring-contextual-options-with-microsoft-extensions-options-contextual-51468.md>)

Original publisher: [Read original article](<https://andrewlock.net/configuring-contextual-options-with-microsoft-extensions-options-contextual/>)

Author: Andrew Lock

Published: 2026-04-01T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [context](<https://devfeed.tech/topics/context.md>), [Library](<https://devfeed.tech/topics/library.md>), [Microsoft](<https://devfeed.tech/topics/microsoft.md>)

Tags: [configuration](<https://devfeed.tech/tags/configuration.md>), [configuration-net-core](<https://devfeed.tech/tags/configuration-net-core.md>), [context](<https://devfeed.tech/tags/context.md>), [di](<https://devfeed.tech/tags/di.md>), [library](<https://devfeed.tech/tags/library.md>), [microsoft](<https://devfeed.tech/tags/microsoft.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>)

### AI overview

This post examines Microsoft.Extensions.Options.Contextual, a .NET library for dynamically configuring options based on a supplied context. It explains the package's purpose, installation and configuration, and contrasts contextual options with global and named options using a weather forecast example.

### Source excerpt

In this post I take a brief look at the Microsoft.Extensions.Options.Contextual package to understand what it's for, how to use it, and whether to use it or not

## Splitting the NetEscapades.EnumGenerators packages: the road to a stable release

DevFeed: [Splitting the NetEscapades.EnumGenerators packages: the road to a stable release](<https://devfeed.tech/articles/splitting-the-netescapades-enumgenerators-packages-the-road-to-a-stable-release-51487.md>)

Original publisher: [Read original article](<https://andrewlock.net/splitting-the-netescapades-enumgenerators-packages-the-road-to-a-stable-release/>)

Author: Andrew Lock

Published: 2026-03-10T09:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [source generators](<https://devfeed.tech/topics/source-generators.md>), [.NET](<https://devfeed.tech/topics/net.md>), [enum](<https://devfeed.tech/topics/enum.md>), [.NET Framework](<https://devfeed.tech/topics/net-framework.md>)

Tags: [changes](<https://devfeed.tech/tags/changes.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [net-core-roslyn-source-generators](<https://devfeed.tech/tags/net-core-roslyn-source-generators.md>), [packages](<https://devfeed.tech/tags/packages.md>), [performance](<https://devfeed.tech/tags/performance.md>), [release](<https://devfeed.tech/tags/release.md>), [roslyn](<https://devfeed.tech/tags/roslyn.md>), [source-generators](<https://devfeed.tech/tags/source-generators.md>)

### AI overview

This post explains the restructuring of the NetEscapades.EnumGenerators source generator NuGet package into three packages ahead of a stable release. It also describes how the generator creates fast enum-handling implementations and compares their performance with built-in approaches across .NET versions.

### Source excerpt

In this post I describe the recent architectural changes to the NetEscapades.EnumGenerators package, which is now a metapackage, to support more scenarios

## Recording metrics in-process using MeterListener: System.Diagnostics.Metrics APIs - Part 4

DevFeed: [Recording metrics in-process using MeterListener: System.Diagnostics.Metrics APIs - Part 4](<https://devfeed.tech/articles/recording-metrics-in-process-using-meterlistener-system-diagnostics-metrics-apis-part-4-51483.md>)

Original publisher: [Read original article](<https://andrewlock.net/recording-metrics-in-process-using-meterlistener/>)

Author: Andrew Lock

Published: 2026-02-24T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [telemetry](<https://devfeed.tech/topics/telemetry.md>), [ASP.NET Core](<https://devfeed.tech/topics/asp-net-core.md>), [ASP.NET](<https://devfeed.tech/topics/aspnet.md>), [Minimal API](<https://devfeed.tech/topics/minimal-api.md>), [OpenTelemetry](<https://devfeed.tech/topics/opentelemetry.md>)

Tags: [aggregate](<https://devfeed.tech/tags/aggregate.md>), [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [diagnostics](<https://devfeed.tech/tags/diagnostics.md>), [http](<https://devfeed.tech/tags/http.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [minimal-api](<https://devfeed.tech/tags/minimal-api.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [observability](<https://devfeed.tech/tags/observability.md>), [observability-net-core](<https://devfeed.tech/tags/observability-net-core.md>), [opentelemetry](<https://devfeed.tech/tags/opentelemetry.md>), [parallel](<https://devfeed.tech/tags/parallel.md>), [recording](<https://devfeed.tech/tags/recording.md>)

### AI overview

A tutorial on using MeterListener to consume and aggregate in-process measurements from the System.Diagnostics.Metrics APIs. It demonstrates a minimal ASP.NET Core app that generates load, listens for measurements, and displays live-updating results.

### Source excerpt

In this post I show how you can use MeterListener to listen to Instrument measurements, how to trigger Observable measurements, and how to aggregate values.

## Creating standard and "observable" instruments: System.Diagnostics.Metrics APIs - Part 3

DevFeed: [Creating standard and "observable" instruments: System.Diagnostics.Metrics APIs - Part 3](<https://devfeed.tech/articles/creating-standard-and-observable-instruments-system-diagnostics-metrics-apis-part-3-51471.md>)

Original publisher: [Read original article](<https://andrewlock.net/creating-standard-and-observable-instruments/>)

Author: Andrew Lock

Published: 2026-02-17T10:00:00Z

Content type: article

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [.NET](<https://devfeed.tech/topics/net.md>), [telemetry](<https://devfeed.tech/topics/telemetry.md>), [ASP.NET Core](<https://devfeed.tech/topics/asp-net-core.md>), [OpenTelemetry](<https://devfeed.tech/topics/opentelemetry.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [examples](<https://devfeed.tech/tags/examples.md>), [gc](<https://devfeed.tech/tags/gc.md>), [heap](<https://devfeed.tech/tags/heap.md>), [http](<https://devfeed.tech/tags/http.md>), [libraries](<https://devfeed.tech/tags/libraries.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [nuget](<https://devfeed.tech/tags/nuget.md>), [observability](<https://devfeed.tech/tags/observability.md>), [observability-net-core](<https://devfeed.tech/tags/observability-net-core.md>), [observable](<https://devfeed.tech/tags/observable.md>), [opentelemetry](<https://devfeed.tech/tags/opentelemetry.md>), [process](<https://devfeed.tech/tags/process.md>)

### AI overview

This post explains the instrument types in the .NET System.Diagnostics.Metrics API, focusing on the difference between standard instruments that emit values as events occur and observable instruments whose values are requested by a metrics consumer. It includes examples from .NET libraries and ASP.NET Core.

### Source excerpt

In this post I discuss the various Instrument types exposed by the System.Diagnostics.Metrics API and show examples from the .NET libraries and ASP.NET Core

## Using Microsoft.Extensions.Telemetry.Abstractions Source Generators for Strongly Typed .NET Metrics

DevFeed: [Using Microsoft.Extensions.Telemetry.Abstractions Source Generators for Strongly Typed .NET Metrics](<https://devfeed.tech/articles/exploring-the-underwhelming-system-diagnostics-metrics-source-generators-system-diagnostics-metrics-apis-part-2-51472.md>)

Original publisher: [Read original article](<https://andrewlock.net/creating-strongly-typed-metics-with-a-source-generator/>)

Author: Andrew Lock

Published: 2026-02-03T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [source generators](<https://devfeed.tech/topics/source-generators.md>), [telemetry](<https://devfeed.tech/topics/telemetry.md>), [.NET](<https://devfeed.tech/topics/net.md>), [Code](<https://devfeed.tech/topics/code.md>), [Microsoft](<https://devfeed.tech/topics/microsoft.md>)

Tags: [boilerplate](<https://devfeed.tech/tags/boilerplate.md>), [documentation](<https://devfeed.tech/tags/documentation.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [observability](<https://devfeed.tech/tags/observability.md>), [observability-net-core](<https://devfeed.tech/tags/observability-net-core.md>), [source-generators](<https://devfeed.tech/tags/source-generators.md>), [telemetry](<https://devfeed.tech/tags/telemetry.md>)

### AI overview

This tutorial explores the source generators in Microsoft.Extensions.Telemetry.Abstractions for creating .NET metrics. It compares the generated approach with manual boilerplate, examines the generated code, and shows how strongly typed tag objects add type safety.

### Source excerpt

In this post I explore the source generators shipped in Microsoft.Extensions.Telemetry.Abstractions, explore the code, and discuss whether I would use them

## Creating and consuming metrics with System.Diagnostics.Metrics APIs: System.Diagnostics.Metrics APIs - Part 1

DevFeed: [Creating and consuming metrics with System.Diagnostics.Metrics APIs: System.Diagnostics.Metrics APIs - Part 1](<https://devfeed.tech/articles/creating-and-consuming-metrics-with-system-diagnostics-metrics-apis-system-diagnostics-metrics-apis-part-1-51470.md>)

Original publisher: [Read original article](<https://andrewlock.net/creating-and-consuming-metrics-with-system-diagnostics-metrics-apis/>)

Author: Andrew Lock

Published: 2026-01-27T10:00:00Z

Content type: tutorial

Language: en

Sources: [Andrew Lock | .NET Escapades](<https://devfeed.tech/sources/andrew-lock-net-escapades.md>)

Topics: [API](<https://devfeed.tech/topics/api.md>), [Monitoring](<https://devfeed.tech/topics/monitoring.md>), [.NET](<https://devfeed.tech/topics/net.md>), [OpenTelemetry](<https://devfeed.tech/topics/opentelemetry.md>), [telemetry](<https://devfeed.tech/topics/telemetry.md>)

Tags: [asp-net-core](<https://devfeed.tech/tags/asp-net-core.md>), [datadog](<https://devfeed.tech/tags/datadog.md>), [diagnostics](<https://devfeed.tech/tags/diagnostics.md>), [dotnet](<https://devfeed.tech/tags/dotnet.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [net](<https://devfeed.tech/tags/net.md>), [net-core](<https://devfeed.tech/tags/net-core.md>), [observability](<https://devfeed.tech/tags/observability.md>), [observability-net-core-datadog](<https://devfeed.tech/tags/observability-net-core-datadog.md>), [opentelemetry](<https://devfeed.tech/tags/opentelemetry.md>)

### AI overview

An introduction to the System.Diagnostics.Metrics API in .NET, covering local metric monitoring, custom metrics, metric types, and interoperability with OpenTelemetry and dotnet-counters.

### Source excerpt

In this post I provide an introduction to the System.Diagnostics.Metrics API, and show how to create a custom metric and read it with dotnet-counters

[Next page](<https://devfeed.tech/sources/andrew-lock-net-escapades.md?cursor=WyIyMDI2LTAxLTI3VDEwOjAwOjAwKzAwOjAwIiwgIjI3ODlmZWZlLWI4MTItNDdlOC1hNzcxLThlOGZmYjlkOTg4OSJd>)