chore: migrate tests to xUnit.net v3, cover both shipped TFMs, repo maintenance - #7
Merged
Merged
Conversation
…aintenance Test framework - xunit 2.9.3 -> xunit.v3 4.0.0 (there is no `xunit` 4.0.0; v3 ships as `xunit.v3`). v3 test projects are self-executing console apps, so the test project is now OutputType=Exe. - v3 4.0.0 runs on Microsoft.Testing.Platform, and MTP dropped VSTest-bridge support on the .NET 10 SDK, so `dotnet test` opts into the MTP runner via a root global.json. `TestingPlatformDotnetTestSupport` is the old path and now hard-errors. - Dropped Microsoft.NET.Test.Sdk and xunit.runner.visualstudio: both are VSTest-only. (xunit.runner.visualstudio 4.0.0 is still the *v2* adapter, not a v3 upgrade path.) - Fixed xUnit2033 in GradientTests, surfaced by v3's analyzers and promoted to an error by TreatWarningsAsErrors. Test coverage - Test project multi-targets net8.0;net10.0, mirroring the library. lib/net8.0 was previously compiled but never executed; the suite now runs once per TFM against its own dependency graph (80 executions). - CI build job installs the 8.0.x runtime alongside 10.0.x. Building an older TFM needs only reference assemblies, but running it needs that runtime, so the previous 10.0.x-only setup would fail the net8.0 leg outright. The build still uses the newest SDK, as global.json carries no `sdk` pin. The publish job stays on 10.0.x since it executes no test code. Fixes - PackageOutputPath is guarded to Windows. With GeneratePackageOnBuild=true the hardcoded C:\nuget-local\ made every non-Windows build create a literal `C:\nuget-local\` directory under src/. - Publish job gains `contents: read`. An explicit `permissions` block sets every unlisted scope to `none`, leaving actions/checkout unable to clone. Cleanup - Removed Microsoft.SourceLink.GitHub; the .NET SDK has bundled SourceLink since .NET 8. Verified pack output is unchanged either way: identical .nuspec repository metadata and .snupkg PDBs still carrying source URLs. - Bumped actions/checkout v6->v7, setup-dotnet v5->v6, upload-artifact v6->v7, download-artifact v7->v8 (all routine dependency/runtime updates; no input changes affecting this workflow) and dropped the now-obsolete FORCE_JAVASCRIPT_ACTIONS_TO_NODE24 transitional flag. - Deduped Nullable/Authors already set by Directory.Build.props. No library code, public API, or shipped package contents changed. Verified: restore/build/test/pack in Release matching CI - 0 warnings, 0 errors, 80/80 tests passing across net8.0 and net10.0, both lib/ assets packed with repository metadata intact. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
xunit → 4.0.0
There is no
xunit4.0.0 — thexunitpackage tops out at 2.9.3. Version 4.0.0 isxunit.v3, so this is a v2 → v3 migration:xunit2.9.3 →xunit.v34.0.0; v3 test projects are self-executing console apps, henceOutputType=Exe.dotnet testopts into the MTP runner via a rootglobal.json;TestingPlatformDotnetTestSupportis the old path and now hard-errors.Microsoft.NET.Test.Sdkandxunit.runner.visualstudio— both VSTest-only. (xunit.runner.visualstudio4.0.0 is still the v2 adapter, not a v3 upgrade path.)GradientTests.cs, surfaced by v3's analyzers and promoted to an error byTreatWarningsAsErrors.Both shipped TFMs are now tested
The library ships
lib/net8.0andlib/net10.0, but the suite ran onnet10.0only —lib/net8.0was compiled, never executed. The test project now multi-targetsnet8.0;net10.0, so the 40 tests run once per TFM against their own dependency graph (80 executions). Confirmed the net8.0 leg binds to the net8.0 asset, not a re-resolved net10 one:CI needed the matching runtime — this was not optional. Building an older TFM needs only reference assemblies, but running it needs that runtime installed, so the previous
10.0.x-only setup failed the net8.0 leg outright:The build job now installs
8.0.xalongside10.0.x. The build still uses the newest SDK, asglobal.jsoncarries nosdkpin. The publish job stays on10.0.x— it executes no test code.sudo apt-get install -y dotnet-runtime-8.0). Otherwise usedotnet test --framework net10.0.Bugs fixed along the way
PackageOutputPathbroke non-Windows builds. WithGeneratePackageOnBuild=true, the hardcodedC:\nuget-local\made every Linux/macOS/CI build write into a literal directory namedC:\nuget-local\undersrc/. Reproduced, then guarded the property to Windows so the local dev feed still works there.permissionsblock listed onlyid-token: write, and GitHub sets every unlisted scope tonone— leavingactions/checkoutwithoutcontents: read. Worth checking whether the v0.3.0 tag publish actually succeeded.Cleanup
Microsoft.SourceLink.GitHub— the .NET SDK has bundled SourceLink since .NET 8. Verified rather than assumed: packed both ways and diffed. Identical.nuspecrepository metadata, and.snupkgPDBs still carryraw.githubusercontentsource URLs, so consumer step-through debugging is unaffected.actions/checkoutv6→v7,setup-dotnetv5→v6,upload-artifactv6→v7,download-artifactv7→v8. Read each release note first — all routine dependency/runtime updates, no input changes affecting this workflow. Dropped the obsoleteFORCE_JAVASCRIPT_ACTIONS_TO_NODE24transitional flag.Nullable/Authorsalready set byDirectory.Build.props.Verification
Full
restore → build → test → packin Release, matching CI:No library code, public API, or shipped package contents changed.
🤖 Generated with Claude Code