From 911083389b7b28045ccebbf3432393d79d6307a4 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Thu, 5 Nov 2026 11:42:14 +0000 Subject: [PATCH 1/2] Fix reported regression fixture compiler warnings (#7642) --- .../AssertionResultExceptionPropagationTests.cs | 2 +- .../Bugs/6767/ExecutorEventReceiverTests.cs | 4 ---- tests/TUnit.TestProject/Bugs/_7118/MixedTypeRowsTests.cs | 8 ++++---- tests/TUnit.TestProject/TestCountVerificationTests.cs | 2 +- tests/TUnit.TestProject/TimeoutCancellationTokenTests.cs | 2 ++ tests/TUnit.TestProject/TransactionTest.cs | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/TUnit.TestProject/AssertionResultExceptionPropagationTests.cs b/tests/TUnit.TestProject/AssertionResultExceptionPropagationTests.cs index da9eaef75f3..cae697286a9 100644 --- a/tests/TUnit.TestProject/AssertionResultExceptionPropagationTests.cs +++ b/tests/TUnit.TestProject/AssertionResultExceptionPropagationTests.cs @@ -32,7 +32,7 @@ public async Task Mapped_Assertion_Failure_Preserves_InnerException() AssertionException? caught = null; try { - await Assert.That(value).Satisfies(v => v.Length, length => length.IsEqualTo(99)); + await Assert.That(value).Satisfies(v => v!.Length, length => length.IsEqualTo(99)); } catch (AssertionException ex) { diff --git a/tests/TUnit.TestProject/Bugs/6767/ExecutorEventReceiverTests.cs b/tests/TUnit.TestProject/Bugs/6767/ExecutorEventReceiverTests.cs index 49ce7dff3c2..f86ed965974 100644 --- a/tests/TUnit.TestProject/Bugs/6767/ExecutorEventReceiverTests.cs +++ b/tests/TUnit.TestProject/Bugs/6767/ExecutorEventReceiverTests.cs @@ -65,8 +65,6 @@ private static async Task MeasureAsync() /// internal sealed class SerialExecutor : GenericAbstractExecutor, ITestRegisteredEventReceiver { - public int Order => 0; - public ValueTask OnTestRegistered(TestRegisteredContext context) { context.SetParallelLimiter(new SerialLimit()); @@ -129,8 +127,6 @@ internal sealed class EqualByTypeExecutor : GenericAbstractExecutor, ITestRegist { public bool IsRegistered { get; private set; } - public int Order => 0; - public ValueTask OnTestRegistered(TestRegisteredContext context) { IsRegistered = true; diff --git a/tests/TUnit.TestProject/Bugs/_7118/MixedTypeRowsTests.cs b/tests/TUnit.TestProject/Bugs/_7118/MixedTypeRowsTests.cs index cb8352fa7bb..0cc01a7eba7 100644 --- a/tests/TUnit.TestProject/Bugs/_7118/MixedTypeRowsTests.cs +++ b/tests/TUnit.TestProject/Bugs/_7118/MixedTypeRowsTests.cs @@ -222,10 +222,10 @@ public async Task Test(T? arg) } } -// A class row [Arguments(null)] declares string, so its null value makes a string instantiation, and +// A class row [Arguments(null!)] declares string, so its null value makes a string instantiation, and // the method row "a" runs on it: Test("a") on with a null constructor value. [EngineTest(ExpectedResult.Pass)] -[Arguments(null)] +[Arguments(null!)] public class NullTypedClassRow(T? value) { [Test] @@ -238,10 +238,10 @@ public async Task Test(T arg) } } -// A class row [Arguments(null)] binds its null value to the constructor's T[] parameter, so it infers T +// A class row [Arguments(null!)] binds its null value to the constructor's T[] parameter, so it infers T // as string, not string[], and the method row "a" runs on with a null constructor value. [EngineTest(ExpectedResult.Pass)] -[Arguments(null)] +[Arguments(null!)] public class ArrayParameterNullTypedClassRow(T[]? values) { [Test] diff --git a/tests/TUnit.TestProject/TestCountVerificationTests.cs b/tests/TUnit.TestProject/TestCountVerificationTests.cs index db7b6eb3cd1..7524fd8283d 100644 --- a/tests/TUnit.TestProject/TestCountVerificationTests.cs +++ b/tests/TUnit.TestProject/TestCountVerificationTests.cs @@ -8,7 +8,7 @@ public class TestCountVerificationTests(int value) [Test] public async Task SimpleTest() { - await Task.CompletedTask; + await Assert.That(value).IsIn(1, 2, 10); } public class TestDataSource diff --git a/tests/TUnit.TestProject/TimeoutCancellationTokenTests.cs b/tests/TUnit.TestProject/TimeoutCancellationTokenTests.cs index d98717f7b86..a8fcefd665c 100644 --- a/tests/TUnit.TestProject/TimeoutCancellationTokenTests.cs +++ b/tests/TUnit.TestProject/TimeoutCancellationTokenTests.cs @@ -106,6 +106,8 @@ public class CancellationTokenTriggeredTests(int value) [Test] public async Task CancellationTokenIsTriggered(CancellationToken cancellationToken) { + await Assert.That(value).IsEqualTo(1); + var fired = false; cancellationToken.Register(() => fired = true); diff --git a/tests/TUnit.TestProject/TransactionTest.cs b/tests/TUnit.TestProject/TransactionTest.cs index 570c14c9ada..5f3dbf4748b 100644 --- a/tests/TUnit.TestProject/TransactionTest.cs +++ b/tests/TUnit.TestProject/TransactionTest.cs @@ -8,7 +8,7 @@ namespace TUnit.TestProject; [EngineTest(ExpectedResult.Pass)] public class TransactionTest { - private TransactionScope _scope; + private TransactionScope _scope = null!; // Initialized by the Before(Test) hook. [Before(Test)] public void Setup(TestContext context) From a856db35cbd463400fe944de1c791958a9d8c717 Mon Sep 17 00:00:00 2001 From: Tom Longhurst <30480171+thomhurst@users.noreply.github.com> Date: Thu, 5 Nov 2026 12:38:40 +0000 Subject: [PATCH 2/2] Update typed null-row generator snapshot for #7642 --- .../Tests7118.Test.verified.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/TUnit.Core.SourceGenerator.Tests/Tests7118.Test.verified.txt b/tests/TUnit.Core.SourceGenerator.Tests/Tests7118.Test.verified.txt index b21706952bb..693845f7876 100644 --- a/tests/TUnit.Core.SourceGenerator.Tests/Tests7118.Test.verified.txt +++ b/tests/TUnit.Core.SourceGenerator.Tests/Tests7118.Test.verified.txt @@ -1629,7 +1629,7 @@ global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "arg", new gl { new global::TUnit.Core.TestAttribute(), new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass), - new global::TUnit.Core.ArgumentsAttribute(null) + new global::TUnit.Core.ArgumentsAttribute(null!) }; } public static readonly global::TUnit.Core.TestEntry>[] Entries_0 = new global::TUnit.Core.TestEntry>[] @@ -1646,7 +1646,7 @@ global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "arg", new gl }, classDataSources: new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ArgumentsAttribute(null), + new global::TUnit.Core.ArgumentsAttribute(null!), }, methodMetadata: __mm_0, createInstance: __CreateInstance_0, @@ -1713,7 +1713,7 @@ global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "arg", new gl { new global::TUnit.Core.TestAttribute(), new global::TUnit.TestProject.Attributes.EngineTest(global::TUnit.TestProject.Attributes.ExpectedResult.Pass), - new global::TUnit.Core.ArgumentsAttribute(null) + new global::TUnit.Core.ArgumentsAttribute(null!) }; } public static readonly global::TUnit.Core.TestEntry>[] Entries_0 = new global::TUnit.Core.TestEntry>[] @@ -1730,7 +1730,7 @@ global::TUnit.Core.ParameterMetadataFactory.Create(typeof(object), "arg", new gl }, classDataSources: new global::TUnit.Core.IDataSourceAttribute[] { - new global::TUnit.Core.ArgumentsAttribute(null), + new global::TUnit.Core.ArgumentsAttribute(null!), }, methodMetadata: __mm_0, createInstance: __CreateInstance_0,