Andrew Lock "Sock"'s Avatar

Andrew Lock "Sock"

@andrewlock

Microsoft MVP and blogger, focused on ASP.​NET Core. Author of ASP.​NET Core in Action (https://mng.bz/5mRz) Blog: https://andrewlock.net Mastadon: @andrewlock@hachyderm.io Twitter: @andrewlocknet

2,397
Followers
340
Following
902
Posts
12.10.2023
Joined
Posts Following

Latest posts by Andrew Lock "Sock" @andrewlock

Preview
Recording metrics in-process using MeterListener: System.Diagnostics.Metrics APIs - Part 4 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.

Blogged: Recording metrics in-process using MeterListener

andrewlock.net/recording-me...

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

#dotnet #observability

24.02.2026 18:04 👍 5 🔁 2 💬 0 📌 0
Preview
Too good to be true: an unexpected profiler trap Sometimes the most convincing performance gains deserve a second look. A reminder that profiling data can be more subtle than it first appears.

I got "tricked" by PerfView when using it to measure the effectiveness of my optimizations, so I decided to write about it: minidump.net/an-unexpecte...
It's not specific to PerfView though, in theory this could happen with any profiler.

20.02.2026 12:47 👍 8 🔁 5 💬 1 📌 0

Ok, so I wrote a very long and kinda personal thing about existential dread and the end of programming, and I'm not really sure I want to endure the discourse, but if you want to read it, it's here - gist.github.com/davidwhitney...

It's like 6,000 words long, sorry.

17.02.2026 21:38 👍 29 🔁 9 💬 10 📌 4

Thanks!

17.02.2026 23:01 👍 1 🔁 0 💬 0 📌 0
Preview
Creating standard and "observable" instruments: System.Diagnostics.Metrics APIs - Part 3 In this post I discuss the various Instrument<T> types exposed by the System.Diagnostics.Metrics API and show examples from the .NET libraries and ASP.NET Core

Blogged: Creating standard and "observable" instruments

andrewlock.net/creating-sta...

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

#dotnet #observability

17.02.2026 17:12 👍 5 🔁 2 💬 1 📌 0
Preview
Add application security to the swiyu generic management verifier APIs using OAuth The article looks at implementing security using OAuth for the swiyu Public Beta Trust Infrastructure generic containers. The container provides endpoint for OpenID verification and the management …

Blogged: Add application security to the swiyu generic management verifier APIs using OAuth

damienbod.com/2026/02/16/a...

#aspnetcore #oauth #swiyu #swiss #openid #yarp #aspire #container #api #iam #security #dotnet

16.02.2026 07:21 👍 1 🔁 1 💬 0 📌 0
Scrolling list of ASP.NET log output

Scrolling list of ASP.NET log output

Show all the routes of a site

Show all the routes of a site

Show all the configuration values for an ASP.NET site and their source

Show all the configuration values for an ASP.NET site and their source

Shows the DI configuration

Shows the DI configuration

If you didn't catch it, this shows the current logs, DI config, environment and ASP.NET routes in the terminal when you do a dotnet run on an ASP.NET app. Combines a bunch of snippets I've borrowed from @meziantou.net and @andrewlock.bsky.social posts and dumping them into the console.

04.02.2026 19:58 👍 4 🔁 1 💬 1 📌 0

In this case "better" is just "more like the original source" ☺️ e.g. dotpeek has two nested for loops like the original, where ilspy has a for and a while.

ILSpy pita the label in the right place though 😅

04.02.2026 18:53 👍 0 🔁 0 💬 0 📌 0
Preview
Exploring the (underwhelming) System.Diagnostics.Metrics source generators: System.Diagnostics.Metrics APIs - Part 2 In this post I explore the source generators shipped in Microsoft.Extensions.Telemetry.Abstractions, explore the code, and discuss whether I would use them

Blogged: Exploring the (underwhelming) System.Diagnostics.Metrics source generators

andrewlock.net/creating-str...

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

#dotnet

03.02.2026 18:10 👍 7 🔁 0 💬 0 📌 0

And thanks to friends in high places (cough @kevingosse.net):

youtrack.jetbrains.com/issue/DOTP-8...

03.02.2026 10:51 👍 3 🔁 0 💬 0 📌 0
The source code for MemoryExtensions.TrimEnd, showing the 'Next' label after the break

The source code for MemoryExtensions.TrimEnd, showing the 'Next' label after the break

The source code for the ILSpy-decompiled version, which uses an inner while loop, but contains the IL_0044 (Next) label at the right place

The source code for the ILSpy-decompiled version, which uses an inner while loop, but contains the IL_0044 (Next) label at the right place

The source code for the dotPeek-decompiled version, which uses an inner while loop, but contains the label_8 (Next) label in the _wrong_ place

The source code for the dotPeek-decompiled version, which uses an inner while loop, but contains the label_8 (Next) label in the _wrong_ place

We discovered something interesting... the decompiled output of ILSpy and dotPeek differs. Which is fine...dotPeek does a "better" job in general... except that in this case, the dotPeek code includes an infinite loop bug 😅

1) Original source for MemoryExtensions.TrimEnd()
2) ILSpy
3) dotPeek

03.02.2026 10:16 👍 5 🔁 0 💬 2 📌 0
Preview
Recent updates to NetEscapades.EnumGenerators: new APIs and System.Memory support In this post I describe some recent changes to the NetEscapades.EnumGenerators source generator, including support for the System.Memory package and new APIs

Speed up enum ToString and parsing with @andrewlock.bsky.social's latest NetEscapades.EnumGenerators update: disable number parsing, serialize in lower or upper invariant, and get span support via System.Memory on older targets.

#csharp #dotnet

29.01.2026 15:49 👍 1 🔁 1 💬 0 📌 0

Yep, easiest way is prob to use the open telemetry Prometheus exporter: learn.microsoft.com/en-us/dotnet...

29.01.2026 02:09 👍 2 🔁 0 💬 0 📌 0
Preview
Creating and consuming metrics with System.Diagnostics.Metrics APIs 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-coutners

Blogged: Creating and consuming metrics with System.Diagnostics.Metrics APIs

andrewlock.net/creating-and...

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

#dotnet

27.01.2026 15:26 👍 8 🔁 3 💬 2 📌 0
Preview
Writing a .NET Garbage Collector in C#  - Part 6: Mark and Sweep Using NativeAOT to write a .NET GC in C#. In the sixth part, we start implementing the mark phase of the garbage collection.

After a long wait, I've finally published the sixth part in my "Writing a .NET Garbage Collector in C#" series. Today, we start implementing mark and sweep.

minidump.net/writing-a-ne...

27.01.2026 10:26 👍 11 🔁 6 💬 0 📌 0
The book "ASP.NET Core In Action" sitting on a desk. The front cover has an image of a man in a robe with a long beard and a tall hat on his head.

The book "ASP.NET Core In Action" sitting on a desk. The front cover has an image of a man in a robe with a long beard and a tall hat on his head.

So I can learn what I need for both a new job and my game, I'm reading the massive ASP.NET Core In Action by @andrewlock.bsky.social. My roommate called it a magical tome and pointed out: there's even a wizard on the cover!

Anyway, now I imagine I'm reading a magical tome for casting complex spells

20.01.2026 14:30 👍 7 🔁 2 💬 0 📌 0

Blogged: Making foreach of an IEnumerable allocation-free, using reflection and dynamic methods

andrewlock.net/making-forea...

In this post I describe why foreach sometimes allocates, and show how you can use DynamicMethod and Reflection.Emit to go allocation-free

#dotnet #csharp

20.01.2026 16:17 👍 4 🔁 0 💬 0 📌 0

Gah, sorry about that, that's embarrassing🤦‍♂️Fixed now

15.01.2026 10:13 👍 0 🔁 0 💬 1 📌 0
Preview
The Windows File Explorer replacement, File Pilot, is awesome In this post I describe my experience with the Windows File Explorer replacement, File Pilot. It's blazingly fast, feature rich, and has hotkeys everywhere

Blogged: The Windows File Explorer replacement, File Pilot, is awesome

andrewlock.net/windows-expl...

In this post I describe my experience with the Windows File Explorer replacement, File Pilot. It's blazingly fast, feature rich, and has hotkeys everywhere

13.01.2026 19:45 👍 20 🔁 2 💬 1 📌 0
Preview
Recent updates to NetEscapades.EnumGenerators: new APIs and System.Memory support In this post I describe some recent changes to the NetEscapades.EnumGenerators source generator, including support for the System.Memory package and new APIs

Blogged: Recent updates to NetEscapades.EnumGenerators: new APIs and System.Memory support

andrewlock.net/updates-to-n...

In this post I describe some recent changes to the NetEscapades.EnumGenerators source generator, including support for the System.Memory package and new APIs

#dotnet

06.01.2026 16:01 👍 6 🔁 1 💬 0 📌 0
Preview
HeroDevs Blog | HeroDevs Joins .NET Security Group: Securing the Future of the .NET Ecosystem HeroDevs joins the .NET Security Group alongside Microsoft, Red Hat, and Canonical to deliver synchronized CVE patches and stronger security for end-of-life .NET systems.

HeroDevs has joined Microsoft, Canonical, and Red Hat as a member of the .NET Security Group www.herodevs.com/blog-posts/h...

06.01.2026 00:58 👍 5 🔁 5 💬 0 📌 0
[HOWTO] Implement Audit Logging in a .NET Core application using Entity Framework Core and Audit.NET This blog post outlines the implementation of audit logging using Audit.NET in .NET Core applications with Entity Framework Core. It discusses the purpose of audit logs, which enhance traceability and compliance, and details the setup process, including modifying the DbContext, creating tracking properties, and configuring audit data storage in a dedicated entity.

Blogged: [HOWTO] Implement Audit Logging in a .NET Core application using Entity Framework Core and Audit.NET

#dotnet #dotnetcore #efcore #auditdotnet #auditing #auditlog #audittrail #traceability

29.12.2025 07:44 👍 2 🔁 2 💬 0 📌 0

@danclarke.com also made the jump recently, in case he has any updates/advice 🙂

27.12.2025 07:18 👍 1 🔁 0 💬 1 📌 0
Preview
Migrating comments from Disqus to giscus In this post I describe a .NET script/tool I created to migrate the comments on my blog posts from my legacy Disqus account to GitHub discussions

Also a great follow up :) andrewlock.net/migrating-co...

26.12.2025 20:33 👍 3 🔁 1 💬 1 📌 0
Spectre.Console Documentation Documentation for Spectre.Console and Spectre.CLI - rich console UI library and command-line application framework for .NET

The new Spectre.Console (and Spectre.Console.Cli) website is now live! 🎉

This is all courtesy of @philco.bsky.social, who has done an amazing job, just as he did with the previous website.

spectreconsole.net

24.12.2025 18:43 👍 45 🔁 13 💬 1 📌 0
https://damienbod.com/2025/12/20/digital-authentication-and-identity-validation/

https://damienbod.com/2025/12/20/digital-authentication-and-identity-validation/

Blogged: Digital Authentication and Identity validation

damienbod.com/2025/12/20/d...

#oidc #identity #iam #swiyu #eid #oauth #dpop #openid #security #ecollecting #authentication #loa #loi #vc #oauth2 #swiss #ch #cybersecurity

20.12.2025 11:36 👍 5 🔁 2 💬 0 📌 0
Preview
Investigating a deadlock in Visual Studio A short investigation that showcases one of the most common problem faced when writing a profiler.

Today I ran into a deadlock in VS2026. I debugged it, and it turned out to be a common issue you may run into when writing a profiler.
I wrote a short article about it: minidump.net/investigatin...

17.12.2025 17:55 👍 8 🔁 4 💬 0 📌 0
Preview
Creating a .NET CLR profiler using C# and NativeAOT with Silhouette In this post I look at how to create a simple .NET profiler. But instead of using C++, the profiler uses C# and NativeAOT with the Silhouette library

Creating a .NET CLR profiler using C# and NativeAOT with Silhouette | by Andrew Lock

buff.ly/8dnlOXH

#dotnet #programming #csharp #profiler #aot

16.12.2025 19:00 👍 6 🔁 3 💬 0 📌 0
Preview
Creating a .NET CLR profiler using C# and NativeAOT with Silhouette In this post I look at how to create a simple .NET profiler. But instead of using C++, the profiler uses C# and NativeAOT with the Silhouette library

Blogged: Creating a .NET CLR profiler using C# and NativeAOT with Silhouette

andrewlock.net/creating-a-d...

In this post I look at how to create a simple .NET profiler. But instead of using C++, the profiler uses C# and NativeAOT with @kevingosse.net's Silhouette library

#dotnet

16.12.2025 18:10 👍 13 🔁 3 💬 0 📌 0
Preview
Trying out the Zed editor on Windows for .NET and Markdown In this post I try out Zed on Windows to see if it can replace my VS Code usages for quick edits of .NET projects and writing Markdown documents

Blogged: Trying out the Zed editor on Windows for .NET and Markdown

andrewlock.net/trying-out-t...

In this post I try out Zed on Windows to see if it can replace my VS Code usages for quick edits of .NET projects and writing Markdown documents.

#dotnet

09.12.2025 18:30 👍 12 🔁 2 💬 3 📌 0