Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 4, 2025

The pipeline was failing on Windows/.NET Framework due to the use of CancellationTokenSource.CancelAsync() in the assertion builder, which is only available in .NET 8.0 and later.

Problem

The error occurred in TUnit.Assertions/AssertionBuilders/AssertionBuilder.cs at line 193:

await cts.CancelAsync();  // ❌ Not available in .NET Framework 4.7.2

This caused unobserved task exceptions and pipeline failures when running tests targeting net472.

Solution

Replaced the async cancellation with the synchronous method that's available across all target frameworks:

cts.Cancel();  // ✅ Available in all .NET versions

Testing

  • ✅ All target frameworks build successfully (net472, net8.0, net9.0)
  • ✅ All 346 assertion tests pass on .NET 9.0
  • ✅ Public API tests pass with no breaking changes
  • ✅ .NET Framework 4.7.2 builds without errors

This is a minimal, surgical fix that maintains full compatibility across all supported .NET versions while resolving the pipeline failure.

Fixes #2729.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Fix Pipeline failing on Windows / .NET Framework Fix .NET Framework compatibility: Replace CancelAsync() with Cancel() Aug 4, 2025
Copilot AI requested a review from thomhurst August 4, 2025 00:22
Copilot finished work on behalf of thomhurst August 4, 2025 00:22
@thomhurst thomhurst marked this pull request as ready for review August 4, 2025 07:59
@thomhurst thomhurst merged commit 60becb3 into main Aug 4, 2025
1 check passed
@thomhurst thomhurst deleted the copilot/fix-2729 branch August 4, 2025 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Pipeline failing on Windows / .NET Framework

2 participants