Content by Andrew Lock (51)
Andrew Lock explains how to avoid some static byte[] allocations—even on .NET Framework—by returning ReadOnlySpan backed by embedded assembly data, and validates the behavior by inspecting generated IL, with a clear rundown of the sharp edges that can accidentally reintroduce allocations.
Andrew Lock explains how to build and publish custom Docker Sandbox templates so AI-agent sandboxes start with the tooling you need, including an example that installs the .NET SDK and a more advanced approach that swaps the base image while reapplying the sandbox layering.
Andrew Lock explains how to run AI coding agents in Docker Sandboxes using the sbx tool, so you can use “dangerous”/YOLO-style agent modes while keeping your host machine isolated, with practical setup steps, network policy notes, and git workflow tips.
Andrew Lock walks through what Microsoft.Extensions.Options.Contextual is, how to wire it up in an ASP.NET Core app (including its source generator and receiver pattern), and why he considers it experimental and usually not worth adopting compared to established feature-flag approaches.
Andrew Lock explains recent architectural changes to the NetEscapades.EnumGenerators package family, guiding .NET developers on choosing the right flavor for their scenario and sharing lessons from evolving the popular source generator library.
Andrew Lock explores how to collect and process application metrics in .NET using MeterListener from System.Diagnostics.Metrics. He explains the MetricManager pattern, in-process aggregation, and visualizing metrics with Spectre.Console.
Andrew Lock provides a deep dive into the various instrument types featured in the System.Diagnostics.Metrics API. The article explores practical examples from .NET libraries and ASP.NET Core to illustrate how developers can record and observe metrics in their applications.
Andrew Lock walks through the System.Diagnostics.Metrics source generators in Microsoft.Extensions.Telemetry.Abstractions, showing how they change metric definitions and call sites, what code they generate, and why he finds the current approach limited compared to writing the metrics code manually.
Andrew Lock provides a comprehensive walkthrough on leveraging System.Diagnostics.Metrics APIs in .NET, guiding developers through instrumentation concepts, monitoring with dotnet-counters, and building custom metrics for production-grade observability.
Andrew Lock explains how to make foreach iteration allocation-free on IEnumerable in .NET, leveraging Reflection.Emit and DynamicMethod for advanced memory optimization, with benchmarks and implications for earlier and modern .NET runtimes.
Andrew Lock summarizes recent improvements to the NetEscapades.EnumGenerators package, including new APIs, advanced parsing options, and System.Memory support, offering insights for .NET developers seeking faster enum operations.
Andrew Lock demonstrates how to create a simple .NET CLR profiler using C# and NativeAOT with the Silhouette library, showing how to hook into assembly load events for custom profiling.
Andrew Lock explores whether the Zed editor on Windows can replace VS Code for .NET and Markdown editing, sharing his installation experience, setup tips, feature comparisons, and impressions.
Andrew Lock explains the recent improvements to NetEscapades.EnumGenerators, a .NET source generator package, including support for [EnumMember], additional analyzers, and bug fixes. Developers gain new metadata options and guidance on edge cases.
Andrew Lock provides a technical walkthrough exploring .NET's boot process using host tracing, offering developers step-by-step insights into muxer, hostfxr, and hostpolicy.dll components.
Andrew Lock reviews the .NET support lifecycle and demonstrates how organizations can avoid risks from unsupported versions by leveraging HeroDevs' Never Ending Support for .NET 6.
Andrew Lock demonstrates improvements to the [UnsafeAccessor] mechanism in .NET 10, focusing on how [UnsafeAccessorType] enables accessing private fields and methods for types without direct references.
Andrew Lock provides an in-depth technical breakdown of the ASP.NET Core CVE-2025-55315 vulnerability, explaining request smuggling, exploitation avenues, and steps for developers to remain secure.
Andrew Lock delves into the quirks of applying metadata to fallback endpoints in ASP.NET Core, providing guidance on best practices for minimal APIs, MVC, and Razor Pages.
Andrew Lock walks through using nuget.org’s Trusted Publishing to publish NuGet packages from a GitHub Actions workflow without storing long-lived API keys, using OIDC token exchange and a nuget.org trust policy to improve publishing security.
Andrew Lock details the development of 'sleep-pc,' a native AOT .NET tool for putting Windows PCs to sleep after a timeout, highlighting his approach, toolchain choices, and packaging for NuGet.
Andrew Lock provides a thorough guide on leveraging the new .NET 10 platform-specific tool features, highlighting technical strategies and trade-offs for maintaining compatibility with older .NET SDKs.
Andrew Lock details how .NET 10 preview improves .NET tool packaging for NuGet with new self-contained and native AOT deployment options, uncovering benefits, limitations, and practical tips for developers.
Andrew Lock explores the complexities of authoring and managing .NET tools, offering practical advice on runtime targeting, manifest management, and CI testing for developers.
Andrew Lock walks through the real-world debugging process for a library loading failure on Alpine Linux when running older .NET Core apps, clearly explaining the steps and ultimate resolution.
Andrew Lock shares his experience porting a .NET library to TUnit, a next-gen C# testing framework, explaining benefits versus xUnit, migration steps, and practical challenges faced.
Andrew Lock explains how to run .NET code in the browser without using Blazor, focusing on browser-side WebAssembly and JavaScript interop techniques, with details relevant to .NET 9 and .NET 10.
In this comprehensive post, Andrew Lock examines the new passkey support introduced in ASP.NET Core Identity and the Blazor Web App template as part of .NET 10 preview 6, explaining both user and implementation perspectives.
In this post, Andrew Lock explores the new 'dnx' command in .NET 10, demonstrating how developers can run .NET tools without installing them. He provides both practical usage examples and an under-the-hood look at the SDK implementation.
In this article, Andrew Lock delves into addressing the longstanding marker attribute issue in source generators for .NET 10, unveiling the new AddEmbeddedAttributeDefinition() API and its impact on Roslyn-based development.
In this post, Andrew Lock provides a detailed walkthrough of C# 14’s new extension members feature in .NET 10, including how to convert existing extension methods, the new syntax, and updates to his NetEscapades.EnumGenerators package.
In this article, Andrew Lock uncovers the internal workings of the upcoming .NET 10 feature that allows developers to run single C# files without a separate project file, detailing how the SDK constructs virtual projects and streamlines the build process.
Andrew Lock introduces and examines the new single-file .NET run experience in .NET 10, highlighting its features, scenarios, and emerging enhancements that simplify C# development.
In this detailed post, Andrew Lock discusses workflows for managing stacked branches in Git. He provides advanced advice on rebasing, merging, and pushing branch stacks to streamline feature development and improve code review processes.
In this post, Andrew Lock delves into the use of stacked branches and PRs in Git, outlining practical workflows and tools for managing complex feature development efficiently.
In this article, Andrew Lock details the process of porting a classic Microsoft XNA 3.1 game from 2009 to MonoGame running on .NET 8. He covers technical steps, challenges, and solutions encountered during the migration.
Andrew Lock offers a step-by-step introduction to MonoGame, explaining its XNA roots, .NET-based setup, essential tools, and sample project structure for modern cross-platform game development.
In this post, Andrew Lock demonstrates how to convert a docker-compose-based deployment for the mailing list manager listmonk into a .NET Aspire app host, leveraging Aspire's modeling tools for improved local development and publish workflows.
In this post, Andrew Lock introduces a method for pushing an entire stack of Git branches using a custom alias, streamlining PR workflows and branch management for large features or incremental development.
Andrew Lock guides readers through extending the .NET AI Chat Web App template to build a chatbot that understands website content and answers with citations. The post includes code examples, insights, and performance observations.