Skip to content

Convert System.Collections.Tests to xUnit v3 - #134029

Open
agocke wants to merge 4 commits into
dotnet:mainfrom
agocke:copilot/xunit3-system-collections
Open

agocke wants to merge 4 commits into
dotnet:mainfrom
agocke:copilot/xunit3-system-collections

Conversation

@agocke

@agocke agocke commented Sep 16, 2026

Copy link
Copy Markdown
Member

This is kind of a trial ballon. My previous attempt here tried to move too much at once and got stuck in mutual incompatibilities. Instead I'm going to try to keep v2 and v3 side-by-side and move over projects one-by-one.

Summary

  • add a per-project UseXUnitV3 opt-in to the libraries test infrastructure
  • build a separate xUnit v3 variant of TestUtilities so v2 and v3 projects can coexist
  • convert the standard desktop/archive System.Collections.Tests path to xUnit v3
  • keep single-file, NativeAOT, ReadyToRun, mobile, browser, and WASI configurations on xUnit v2 for this pilot

Note

This pull request description was generated with GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21b4fbf8-d548-4f4d-a033-aa8e36080965
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21b4fbf8-d548-4f4d-a033-aa8e36080965
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-infrastructure-libraries
See info in area-owners.md if you want to be subscribed.

Keep the console runner targets and TestUtilities project identities separate while sharing the common TestUtilities source definition.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21b4fbf8-d548-4f4d-a033-aa8e36080965
Use xunit.v3.assert throughout xUnit v3 builds and keep the project allowlist in shared library test infrastructure.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 21b4fbf8-d548-4f4d-a033-aa8e36080965
@agocke
agocke marked this pull request as ready for review September 17, 2026 05:57
Copilot AI lite review requested due to automatic review settings September 17, 2026 05:57
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
13 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical build, runner, filtering, and legacy-configuration compatibility issues remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 4 High severity

Open (4)
What changed in this PR

This pull request pilots per-project xUnit v3 support for System.Collections.Tests while retaining xUnit v2 for special configurations.

Changes:

  • Adds xUnit v3 selection and runner infrastructure.
  • Provides separate v2/v3 TestUtilities projects.
  • Updates test data access and compatibility helpers.
File Review
src/​libraries/​System.Collections/​tests/​Generic/​Comparers/​EqualityComparer.Tests.cs Critical: v2 configurations can fail to compile due to unguarded v3 theory-data access.
src/​libraries/​Directory.Build.props Reviewed configuration selection.
src/​libraries/​Common/​tests/​TestUtilities/​TestUtilities.XUnitV3.csproj Reviewed v3 utility project definition.
src/​libraries/​Common/​tests/​TestUtilities/​TestUtilities.Shared.props Reviewed shared utility configuration.
src/​libraries/​Common/​tests/​TestUtilities/​TestUtilities.csproj Reviewed v2 utility configuration.
src/​libraries/​Common/​tests/​TestUtilities/​TestEventListener.cs Reviewed v2/v3 output compatibility.
src/​libraries/​Common/​tests/​TestUtilities/​RandomTestCollectionOrderer.cs Reviewed collection ordering compatibility.
src/​libraries/​Common/​tests/​TestUtilities/​RandomTestCaseOrderer.cs Reviewed test-case ordering compatibility.
eng/​testing/​xunit/​xunit.targets Critical: disabling the required apphost and using dotnet exec may prevent the v3 runner from initializing.
eng/​testing/​xunit/​xunit.props Critical: excluding build assets prevents the xUnit v3 entry point from being supplied.
eng/​testing/​xunit/​xunit.console.v3.targets Critical: the trait exclusion switch is invalid and causes argument parsing failures.


<!-- Add to run argument string -->
<RunScriptCommand>$(RunScriptCommand)$(_withCategories.Replace(';', ' -trait category='))</RunScriptCommand>
<RunScriptCommand>$(RunScriptCommand)$(_withoutCategories.Replace(';', ' -trait- category='))</RunScriptCommand>
<!-- Excluding xunit.core/build as it enables deps file generation. -->
<PackageReference Include="xunit.core" Version="$(XUnitVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true" ExcludeAssets="build" />
<PackageReference Include="xunit.core" Version="$(XUnitVersion)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true" ExcludeAssets="build" Condition="'$(UseXUnitV3)' != 'true'" />
<PackageReference Include="xunit.v3.core" Version="$(XUnitV3Version)" IsImplicitlyDefined="true" PrivateAssets="all" Publish="true" ExcludeAssets="build" Condition="'$(UseXUnitV3)' == 'true'" />

<Import Project="$(MSBuildThisFileDirectory)xunit.console.targets" />
<PropertyGroup Condition="'$(UseXUnitV3)' == 'true' and '$(TestSingleFile)' != 'true'">
<UseAppHost>false</UseAppHost>
Comment on lines +19 to +20
return this.Select(row => row.Data.Item1)
.Concat(this.Select(row => row.Data.Item2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants