From 7d1e572d6cfb6c05fea522bc7dbb8e0c143f4576 Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 29 Aug 2026 10:21:29 -0700 Subject: [PATCH 1/3] Migrate Test Project to Native Microsoft.Testing.Platform The .NET 10 SDK dropped the VSTest bridge that dotnet test relied on, so dotnet test failed outright: 'Testing with VSTest target is no longer supported by Microsoft.Testing.Platform on .NET 10 SDK and later.' Opt UtilitiesTests into native MTP (global.json test.runner, the UseMicrosoftTestingPlatformRunner project property) and swap coverlet.collector, a VSTest-only collector, for the native Microsoft.Testing.Extensions.CodeCoverage provider. Bump Microsoft.NET.Test.Sdk and the xunit.v3 family to the versions that ship a compatible Microsoft.Testing.Platform runtime; the prior xunit.v3 3.2.2 pairing threw a TypeLoadException against the newer platform assembly. Update the validate workflow's dotnet test invocation to match (--coverage instead of --collect), naming the output file explicitly: the extension's default GUID basename is not matched by codecov-action's file finder, so the upload step would otherwise silently find nothing under fail_ci_if_error: false. Also fixes three ExtensionsTests.cs null-argument tests that were missing the null-forgiving operator its sibling test already used; TreatWarningsAsErrors never reached these under the old VSTest error, which aborted the build before compiling the test project. --- .github/workflows/validate-task.yml | 9 +++++++-- Directory.Packages.props | 10 +++++----- Utilities.slnx | 1 + UtilitiesTests/ExtensionsTests.cs | 6 +++--- UtilitiesTests/UtilitiesTests.csproj | 11 +++++++---- global.json | 5 +++++ 6 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 global.json diff --git a/.github/workflows/validate-task.yml b/.github/workflows/validate-task.yml index e0567d2..db8bca1 100644 --- a/.github/workflows/validate-task.yml +++ b/.github/workflows/validate-task.yml @@ -24,9 +24,14 @@ jobs: uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 # Builds with TreatWarningsAsErrors, so analyzer and code-style warnings fail here. - # --collect drives coverlet.collector to emit Cobertura XML into ./coverage//. + # dotnet test runs on native Microsoft.Testing.Platform (global.json test.runner); --coverage + # drives Microsoft.Testing.Extensions.CodeCoverage to emit Cobertura XML into ./coverage/. + # --coverage-output names the file explicitly: the default is a GUID basename that + # codecov-action's file finder does not match, so the upload step would silently find nothing. - name: Run unit tests step - run: dotnet test --collect:"XPlat Code Coverage" --results-directory ./coverage + run: >- + dotnet test --coverage --coverage-output-format cobertura + --coverage-output coverage.cobertura.xml --results-directory ./coverage # Report-only: fail_ci_if_error is false so a Codecov hiccup or an absent token never fails the gate. - name: Upload coverage to Codecov step diff --git a/Directory.Packages.props b/Directory.Packages.props index 1813bcb..d4c69f3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,16 +1,16 @@ - - + + - - - + + + diff --git a/Utilities.slnx b/Utilities.slnx index a0cdada..fe43668 100644 --- a/Utilities.slnx +++ b/Utilities.slnx @@ -9,6 +9,7 @@ + diff --git a/UtilitiesTests/ExtensionsTests.cs b/UtilitiesTests/ExtensionsTests.cs index 63e61d8..aa22f7b 100644 --- a/UtilitiesTests/ExtensionsTests.cs +++ b/UtilitiesTests/ExtensionsTests.cs @@ -93,7 +93,7 @@ public void StringExtension_Compress_WithNullString_ShouldThrow() string? nullString = null; _ = FluentActions - .Invoking(() => nullString.Compress()) + .Invoking(() => nullString!.Compress()) .Should() .Throw(); } @@ -211,7 +211,7 @@ public async Task StringExtension_CompressAsync_WithNullString_ShouldThrow() string? nullString = null; _ = await FluentActions - .Awaiting(() => nullString.CompressAsync()) + .Awaiting(() => nullString!.CompressAsync()) .Should() .ThrowAsync(); } @@ -222,7 +222,7 @@ public async Task StringExtension_DecompressAsync_WithNullString_ShouldThrow() string? nullString = null; _ = await FluentActions - .Awaiting(() => nullString.DecompressAsync()) + .Awaiting(() => nullString!.DecompressAsync()) .Should() .ThrowAsync(); } diff --git a/UtilitiesTests/UtilitiesTests.csproj b/UtilitiesTests/UtilitiesTests.csproj index 6d87d47..6ebdb3f 100644 --- a/UtilitiesTests/UtilitiesTests.csproj +++ b/UtilitiesTests/UtilitiesTests.csproj @@ -2,6 +2,10 @@ true ptr727.Utilities.Tests + + Exe + true @@ -12,10 +16,9 @@ runtime; build; native; contentfiles; analyzers; buildtransitive - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/global.json b/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} From 790a5f5c5dee341320dccc4f40094f88be9badae Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 29 Aug 2026 10:24:40 -0700 Subject: [PATCH 2/3] Fix global.json Line Endings to CRLF This repo's .editorconfig pins CRLF for *.json/*.jsonc; the file was written LF, which editorconfig-checker in the Lint job caught. --- global.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/global.json b/global.json index 3140116..7ec050f 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ -{ - "test": { - "runner": "Microsoft.Testing.Platform" - } -} +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} From 99af69fbe26831a55054f9dffbfa04b17564518c Mon Sep 17 00:00:00 2001 From: Pieter Viljoen Date: Sat, 29 Aug 2026 10:27:45 -0700 Subject: [PATCH 3/3] Mark CodeCoverage Extension as Test-Only Dependency Matches the PrivateAssets treatment already used for coverlet.collector and xunit.analyzers, per Copilot review on PR #447. IncludeAssets keeps 'compile', unlike coverlet.collector: the MTP self-registration code generated for the test project references this extension's types directly, so excluding compile assets breaks the build. --- UtilitiesTests/UtilitiesTests.csproj | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/UtilitiesTests/UtilitiesTests.csproj b/UtilitiesTests/UtilitiesTests.csproj index 6ebdb3f..210db32 100644 --- a/UtilitiesTests/UtilitiesTests.csproj +++ b/UtilitiesTests/UtilitiesTests.csproj @@ -18,7 +18,12 @@ - + + + all + compile; runtime; build; native; contentfiles; analyzers; buildtransitive +