Upgrading a .NET 5 "Startup-based" app to .NET 6: Exploring .NET 6 - Part 12
In this short post I tackle a question I have received several times—"how can I update an ASP.NET Core 5 app that uses Startup to .NET 6's minimal hosting APIs"? Background: Minimal Hosting in .NET 6...
View ArticleCreating an incremental generator: Creating a source generator - Part 1
This post is my contribution to the .NET Advent calendar be sure to check there for other great posts! In this post I describe how to create an incremental source generator. As a case study, I...
View ArticleTesting an incremental generator with snapshot testing: Creating a source...
In my previous post, I showed in detail how to create a source generator, but I missed out one very important step: testing. In this post I describe one of the ways I like to test my source generators,...
View ArticleIntegration testing and NuGet packaging: Creating a source generator - Part 3
In the first post in this series, I described how to create a .NET 6 incremental source generator, and in the second post I described how to unit-test your generators using snapshot testing with...
View ArticleCustomising generated code with marker attributes: Creating a source...
In the previous posts in this series I showed how to create an incremental source generator, how to unit and integration test it, and how to package it in a NuGet package. In this post I describe how...
View ArticleFinding a type declaration's namespace and type hierarchy: Creating a source...
In this next post on source generators, I show a couple of common patterns that I've needed when building source generators, namely: How to determine the namespace of a type for a given...
View ArticleSaving source generator output in source control: Creating a source generator...
In this post I describe how to persist the output of your source generator to disk so that it can be part of source control and code reviews, how to control where the files are output, and how to...
View ArticleSolving the source generator 'marker attribute' problem - Part 1: Creating a...
In this post I describe a problem I've been wrestling with around source generators: where to put the 'marker attributes' that drive the source generator. In this post I describe what marker attributes...
View ArticleSolving the source generator 'marker attribute' problem - Part 2: Creating a...
In the previous post I described marker attributes, how they're used by source generators, and the problem with deciding how they should be referenced in a user's project. In this post I describe some...
View ArticleNetEscapades.EnumGenerators: a source generator for enum performance
In this post I describe a source generator I created to improve the performance of enum operations. It is available as a NuGet package, so you're free to use it in your projects too! The...
View ArticleWaiting for your ASP.NET Core app to be ready from an IHostedService in .NET 6
In this post I describe how you can wait for your ASP.NET Core app to be ready to receive requests from inside an IHostedService/BackgroundService in .NET 6. This can be useful if your IHostedService...
View ArticlePlease stop lying about .NET Standard 2.0 support!
This post is a bit of a rant about an issue I've been fighting against more and more recently: NuGet packages lying about supporting .NET Standard 2.0 when they don't, because they don't work on .NET...
View ArticleCancelling await calls in .NET 6 with Task.WaitAsync()
In this post I discuss the new Task.WaitAsync() APIs introduced in .NET 6, how you can use them to "cancel" an await call, and how they can replace other approaches you may be using currently. The new...
View ArticleA deep-dive into the new Task.WaitAsync() API in .NET 6
In this post I look at how the new Task.WaitAsync() API is implemented in .NET 6, looking at the internal types used to implement it. Adding a timeout or cancellation support to await Task In my...
View ArticleJust because you stopped waiting for it, doesn't mean the Task stopped running
At the end of my previous post, in which I took a deep-dive into the new .NET 6 API Task.WaitAsync(), I included a brief side-note about what happens to your Task when you use Task.WaitAsync(). Namely,...
View ArticleTracking down a hanging xUnit test in CI: building a custom Test Framework
In this post I describe how we tracked down a hanging xUnit test in our CI build. To achieve that, we wanted to have xUnit log which tests were running. This proved much harder than we had planned, and...
View ArticleWorking on two git branches at once with git worktree
In this post I describe some scenarios in which you need to change git branches frequently and why this can sometimes be annoying. I then present some possible ways to avoid having to change branch....
View ArticleKeeping up with .NET: learning about new features and APIs
In a recent post I looked at a new API, Task.WaitAsync(), introduced in .NET 6. This new API was pointed out to me by Andreas Gehrke on Twitter, but it raises an interesting point: how can you keep...
View ArticleRunning JavaScript inside a .NET app with JavaScriptEngineSwitcher
I was working on a side project the other day, and realised I really needed to use some JavaScript functionality. The thought of dealing with Node.js and npm again totally put me off, so I decided to...
View ArticleWhy isn't my ASP.NET Core app in Docker working?
In this post I describe a problem I ran into the other day that had me stumped briefly—why doesn't my ASP.NET Core app running in Docker respond when I try and navigate to it? The problem was related...
View Article