Files
frameledger/tests/FrameLedger.Agent.Tests/HostBackgroundFailureTests.cs
poli0981andClaude Fable 5.2 49d7bd8e51 build: the main line on .NET 11 - SDK 11.0.100, net11.0, the three runtime-serviced packages at 11.0.0; Windows 10 stated as untested and unsupported (D94, D95) (beta.37 PR-1) (#376)
* build: the main line on .NET 11 - SDK 11.0.100, net11.0, the three runtime-serviced packages at 11.0.0; Windows 10 stated as untested and unsupported (D94, D95) (beta.37 PR-1)

The owner moved the main line to .NET 11 the day after it shipped (D94),
setting aside condition (a) of 20_OPEN_QUESTIONS section G's table - two
alphas on the released runtime. This is the alpha branch's switch applied
to main at released versions, and what follows from it.

- global.json 11.0.100 (allowPrerelease false), TFM
  net11.0-windows10.0.22621.0, Microsoft.Extensions.Hosting,
  Microsoft.Data.Sqlite and System.Diagnostics.EventLog 11.0.0;
  legal/licenses/nuget regenerated (78 packages -> 69).
- Two CA1307 sites the released SDK raised in tests written after the
  last alpha was cut take the (char, StringComparison) overload.
- IHost.RunAsync rethrows a failed BackgroundService on .NET 11: the
  Agent's --serve leaves through its crash report where it exited 0.
  Accepted, not wrapped; HostBackgroundFailureTests holds the runtime's
  behaviour, which nothing had observed.
- release.yml installs a .NET 10 runtime for vpk 1.2.161; Qodana's
  container installs the .NET 11 SDK first (interim, until the Ultimate
  linter); Dependabot's and the workflows' comments follow.
- Windows 10 22H2 is not blocked, and is stated as untested and
  unsupported (D95): NFR-8, LIMITATIONS, README, the guide, the wiki.
  A processor needs SSE4.2 and POPCNT.
- docs: 12_BUILD (the main line's .NET; the alpha line rests after
  alpha.4, D98), 13_CI_CD, 20_OPEN_QUESTIONS row closed, 10_LOGGING,
  spike-notes section 28, CLAUDE.md, the decisions index (D94-D96, D98).

Gate on the dev box: all passed in 338 s on SDK 11.0.100 (native 32/32,
2,561 tests, coverage floors held).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

* build: what this pull request's runs measured on .NET 11 - CodeQL reads net11.0 whole, the delta from beta.36, Qodana's one finding fixed

- HostBackgroundFailureTests: the message is kept rather than the
  exception, so no `!` is needed - the one problem Qodana's interim run
  reported (run 42916491047, InspectCode 2026.2.3.1 on SDK 11.0.100).
- 13_CI_CD: what analyze (csharp, none) read of net11.0 (CodeQL 2.27.4,
  "scanned 1220 out of 1220 C# files", 363 references resolved, none
  unresolved), and the rule for C# 15 constructs (D96); the interim's
  first run.
- spike-notes section 28: the table of this pull request's runs - check,
  CodeQL, SonarCloud, Qodana, and the release rehearsal with the first
  delta across two runtime majors (72.6 MB, 372 of 443 files patched).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-10 23:13:00 +00:00

52 lines
2.0 KiB
C#

// SPDX-License-Identifier: GPL-3.0-only
// Copyright (C) 2026 poli0981 - additional terms under GPLv3 section 7: see NOTICE
using FluentAssertions;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace FrameLedger.Agent.Tests;
/// <summary>
/// .NET 11, the main line's runtime since 0.1.0-beta.37 (D94): a host whose <see cref="BackgroundService"/> throws stops
/// AND fails - <c>RunAsync</c> rethrows the service's exception, where .NET 10 completed it and the Agent exited 0. The
/// Agent's <c>--serve</c> awaits <c>RunAsync</c> and catches nothing, so that exception is what takes <c>Program.Main</c>
/// to its crash report (<c>10_LOGGING</c> §Crash handling). Microsoft documents the change, three alphas shipped with it,
/// and nothing had observed it until this test (<c>spike-notes</c> §24).
/// </summary>
public sealed class HostBackgroundFailureTests
{
private static CancellationToken Ct => TestContext.Current.CancellationToken;
[Fact]
public async Task AHostWhoseBackgroundServiceThrowsFailsRunAsyncWithThatException()
{
HostApplicationBuilder builder = Host.CreateApplicationBuilder();
builder.Services.AddHostedService(static _ => new Failing());
using IHost host = builder.Build();
// Bounded: a runtime that stopped the host without failing it would complete here, and one that did neither
// would otherwise hang the suite.
string? failure = null;
try
{
await host.RunAsync(Ct).WaitAsync(TimeSpan.FromSeconds(30), Ct);
}
catch (InvalidOperationException ex)
{
failure = ex.Message;
}
failure.Should().Be("the watcher broke", "the host stops and fails when a background service throws");
}
private sealed class Failing : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
await Task.Yield();
throw new InvalidOperationException("the watcher broke");
}
}
}