Retargeting to .NET 11 compiles clean. Six behaviour changes that alter your results anyway, and the canary tests that catch them
The breaking-change list for .NET 11 is mostly behavioural, which means the compiler stays quiet. Six xUnit canaries, passing on net10.0 today, tell you which ones your code depends on.

.NET 11 shipped on 10 November 2026, and Microsoft’s announcement says the same thing as every release: installing the SDK doesn’t retarget your app. When it does, the compiler is the least useful reviewer in the room. Almost every item on the breaking changes list is marked as a behavioural change, which means the code builds, the type checker is happy, and a number somewhere comes out different.
That matters more than usual right now, because .NET 8 and 9 both left support on 10 November, and “bump the target framework” is an easy instruction to hand an agent. It will do that, run the tests, see green and stop. Whether green means anything depends on whether your tests happen to exercise the six changes below.
The list is Microsoft’s own and it’s labelled a work in progress, so it isn’t complete. These six were picked because ordinary web and worker code reaches them without anyone writing anything exotic. Examples stay on net10.0, the project’s baseline and an LTS release. This piece is about knowing what moves before you decide to move.
The six, with the before and after
Every “after” below is the documented .NET 11 behaviour. None of it was run on .NET 11.
Rounding. Math.Round(value, digits, mode) used to scale by a power of ten, round, and scale back. Microsoft says roughly 5% of random inputs came out wrong. The documented example is Math.Round(655.925, 2, MidpointRounding.AwayFromZero): 655.93 before, 655.92 now, because the double is stored as 655.92499999999995 and the old arithmetic nudged it over the midpoint. The new result matches what ToString("F2") already printed. If invoices, tax or pricing go through double, totals can shift by a penny on specific values.
Double to decimal. (decimal)1.23 used to keep 15 significant digits and print 1.23. In .NET 11 the conversion is exact, so it prints 1.229999999999999982236431606. Decimal to double and BigInteger to double changed too, both now rounded once instead of twice. One detail in the docs is easy to miss: a conversion the compiler evaluates as a constant can embed the new value when the project is rebuilt with the .NET 11 SDK, whatever the target framework is. There is no switch to restore the old behaviour.
Chained configuration. AddConfiguration(inner) used to treat an empty string in inner as “not found”, so an earlier provider’s value survived. Now the empty string wins. Endpoint set to https://example.com and then overridden by an empty chained value used to read as the URL and now reads as an empty string. Binding an empty string over a number into an int property throws InvalidOperationException. Again, no compatibility switch.
DateOnly and TimeOnly parsing. TryParse and TryParseExact returned false when given an invalid DateTimeStyles value or format specifier. They now throw ArgumentException. A method named Try throwing is exactly the kind of thing a catch-free code path won’t survive.
DI scope disposal. If a scoped service throws from Dispose, the container used to stop at the first failure and leave the remaining services undisposed. It now attempts every service in reverse order and then rethrows. One failure rethrows as itself and several arrive wrapped in an AggregateException, so a catch (InvalidOperationException) around scope disposal can miss the second case.
Background service failures. When a BackgroundService throws from ExecuteAsync and BackgroundServiceExceptionBehavior is StopHost (the default), RunAsync used to complete normally and the process typically exited with code 0. In .NET 11 it throws and the exit code is non-zero. That’s the right behaviour. It’s also the one that turns a quiet worker into a crash-looping container the first night after the upgrade.
The canaries
The idea is to pin today’s behaviour in tests that pass on the framework you run now, then retarget and read the failures. Put this in a test project that references the same packages your app uses. The assertions are deliberately the old values, so a red test means “this moved”, not “this is a bug”.
using System.Globalization;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Xunit;
namespace Canary;
public class RetargetCanaries
{
[Fact]
public void Round_midpoint_lookalike_rounds_up()
{
Assert.Equal(655.93, Math.Round(655.925, 2, MidpointRounding.AwayFromZero));
}
[Fact]
public void Double_to_decimal_keeps_fifteen_digits()
{
var converted = (decimal)1.23;
Assert.Equal("1.23", converted.ToString("G29", CultureInfo.InvariantCulture));
}
[Fact]
public void Empty_chained_value_does_not_override_earlier_provider()
{
IConfiguration inner = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?> { ["Endpoint"] = "" })
.Build();
IConfiguration configuration = new ConfigurationBuilder()
.AddInMemoryCollection(new Dictionary<string, string?> { ["Endpoint"] = "https://example.com" })
.AddConfiguration(inner)
.Build();
Assert.Equal("https://example.com", configuration["Endpoint"]);
}
[Fact]
public void Invalid_styles_make_dateonly_tryparse_return_false()
{
var ok = DateOnly.TryParseExact("2023-10-15", "yyyy-MM-dd",
CultureInfo.InvariantCulture, (DateTimeStyles)999, out _);
Assert.False(ok);
}
[Fact]
public void Failing_scope_disposal_stops_at_first_exception()
{
var disposed = new List<string>();
var services = new ServiceCollection();
services.AddScoped<First>(_ => new First(disposed));
services.AddScoped<Second>(_ => new Second(disposed));
using var provider = services.BuildServiceProvider();
var scope = provider.CreateScope();
scope.ServiceProvider.GetRequiredService<First>();
scope.ServiceProvider.GetRequiredService<Second>();
Assert.Throws<InvalidOperationException>(scope.Dispose);
Assert.Equal(new[] { "Second" }, disposed);
}
[Fact]
public async Task Failed_background_service_lets_RunAsync_complete()
{
var builder = Host.CreateApplicationBuilder();
builder.Services.AddHostedService<Crasher>();
using var host = builder.Build();
await host.RunAsync();
}
private sealed class First(List<string> log) : IDisposable
{
public void Dispose() { log.Add("First"); throw new InvalidOperationException("first"); }
}
private sealed class Second(List<string> log) : IDisposable
{
public void Dispose() { log.Add("Second"); throw new InvalidOperationException("second"); }
}
private sealed class Crasher : BackgroundService
{
protected override Task ExecuteAsync(CancellationToken stoppingToken)
=> throw new InvalidOperationException("boom");
}
}
The project file needs Microsoft.NET.Test.Sdk, xunit, xunit.runner.visualstudio and Microsoft.Extensions.Hosting. On SDK 10.0.115 with net10.0 and xunit 2.9.3, dotnet test prints:
Passed! - Failed: 0, Passed: 6, Skipped: 0, Total: 6, Duration: 216 ms - Canary.dll (net10.0)
That’s the baseline. Per the pages cited above, switching TargetFramework to net11.0 and bumping the Microsoft.Extensions.* packages should turn all six red, with these messages in roughly this shape: Expected: 655.93, Actual: 655.92; Expected: "1.23" against the 28-digit string; Expected: "https://example.com" against an empty string; a thrown ArgumentException mentioning style; Assert.Throws receiving an AggregateException; and an unhandled InvalidOperationException: boom out of RunAsync. That prediction comes from the documentation, so treat the first real run as the confirmation.
What to do with the red tests
Each failure is a question for a human, and the answer is rarely “put the old value back”.
The rounding and conversion changes are corrections. If the money in your system is a double, the fix is decimal and m literals, and the .NET 11 page for conversions says as much: write 123.4567m, not (decimal)123.4567. The configuration change has the usual fix of removing the key from the chained source or making it null, and the docs confirm there’s no switch for it. The DateOnly change means checking whether any code path can actually pass an invalid style, which is almost always a bug you now get to see.
The two hosting changes are the ones to review hardest. A worker that used to exit 0 on failure will now trigger restart policies, alerts and, in an orchestrator, back-off loops. Decide deliberately whether you want that, and if you want the old exit code, Microsoft’s recommended workaround is a try/catch around RunAsync, which should be a conscious line in Program.cs and not an accident.
Giving this to an agent
The canaries only help if the agent can’t make them go green by editing them. Say so in the task: the files in the canary project are read-only, a failing canary gets reported with the assertion output and left failing, and the agent proposes the code change separately. The same applies to any agent that can read files and run a shell. The prompt and the check, a failing test named for a behaviour, work the same everywhere.
Also keep the scope honest. The canary suite covers six documented changes, not the several dozen on the list, and the list itself says it’s incomplete. Skim the full index
for the areas you use (networking, Uri parsing and the SDK and MSBuild section are the next candidates) and add a canary for each one that touches your code.
Stay on .NET 10 if nothing forces the move. It’s an LTS release, and .NET 11 is Standard Term Support with two years of support, per the announcement. The canaries cost an afternoon and work for either decision, so write them before the retarget branch exists.