Skip to content

Prepare for xunit.v3.assert migration: forward-compatibility changes#125413

Draft
Copilot wants to merge 9 commits intomainfrom
copilot/migrate-to-xunit-assert-v3
Draft

Prepare for xunit.v3.assert migration: forward-compatibility changes#125413
Copilot wants to merge 9 commits intomainfrom
copilot/migrate-to-xunit-assert-v3

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

Description

Prepares the codebase for a future migration to xunit.v3.assert by making forward-compatible changes that work with the current Microsoft.DotNet.XUnitAssert/xunit.assert packages. No actual package switch is made.

EqualException.ForMismatchedValues string conversions: Updated all ForMismatchedValues(object, object) call sites across test files to pass string arguments instead, which is compatible with both the current packages and future xunit.v3.assert (which only accepts strings). Affected files include test code in System.Runtime, System.Numerics.Tensors, System.Runtime.Numerics, System.Runtime.InteropServices, System.Globalization, Microsoft.Extensions.Logging, ICollectionTest, and Wasm.Build.Tests.

xUnit1051 analyzer suppression: Added suppression for xUnit1051 (which recommends TestContext.Current.CancellationToken, a v3 pattern not yet adopted) in .editorconfig, eng/testing/xunit/xunit.props, and src/tests/Directory.Build.props.

GroupCollectionTests2.cs collection comparison fix: Changed Assert.Equal(col, items) to Assert.Equal(col.Cast<Group>(), items) for forward-compatible collection comparison behavior with xunit v3.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 10, 2026 20:46
…sert

Replace all references to Microsoft.DotNet.XUnitAssert and xunit.assert
with xunit.v3.assert (v3.2.2 via $(XUnitV3Version) from Arcade SDK).

This removes the conditional split between .NETCoreApp and non-.NETCoreApp
targets since xunit.v3.assert supports both via netstandard2.0 and net8.0.

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
@agocke
Copy link
Member

agocke commented Mar 10, 2026

This is to test for xunit3-specific breaking changes.

agocke and others added 3 commits March 10, 2026 19:36
…Values calls

- Suppress xUnit1051 (TestContext.Current.CancellationToken) in xunit.props
  since only the assert package is migrated, not the full v3 test patterns.
- Update all EqualException.ForMismatchedValues(object, object, string) calls
  to use the new string-based overload ForMismatchedValues(string, string, string)
  as the object overload is obsolete in xunit.v3.assert.

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

- Add xUnit1051 suppression to .editorconfig (dotnet_diagnostic severity=none)
  for robustness against projects that reset NoWarn
- Add xUnit1051 to src/tests/Directory.Build.props for CoreCLR tests
- Fix CS0618 in TestUtils.cs: use string interpolation for non-nullable args

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

The ILLinker descriptor referenced the old assembly name, causing
NativeAOT and trimming builds to fail with IL2007/MSB3073 errors.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service bot added the linkable-framework Issues associated with delivering a linker friendly framework label Mar 11, 2026
agocke and others added 3 commits March 10, 2026 22:06
….v3.assert

The rd.xml was using the type name as the assembly name. The actual
.NET assembly name for xunit.v3.assert is 'xunit.v3.assert' (lowercase).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Update 3 IL test files to reference xunit.v3.assert (v3.2.2.0) instead
  of the old xunit.assert (v2.4.2.0) assembly
- Fix GroupCollectionTests2.DebuggerAttributeTests: use Cast<Group>() to
  ensure both sides enumerate as IEnumerable<Group> for xunit v3 collection
  comparison

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
These files reference assembly names used by the ILLinker and NativeAOT
trimmer. The xunit.v3.assert assembly needs to be recompiled with AOT
support enabled separately; updating these names without that causes
more failures than it fixes.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@agocke agocke force-pushed the copilot/migrate-to-xunit-assert-v3 branch from 90a9241 to 0293950 Compare March 11, 2026 07:27
@agocke
Copy link
Member

agocke commented Mar 11, 2026

@copilot please revert the actual switch to the xunit.v3.assert package, but keep the changes needed to provide compatibility (except where they were made solely to adapt to assembly name).

Reverts all package reference changes back to the original
Microsoft.DotNet.XUnitAssert/xunit.assert packages. Also reverts
IL assembly extern name changes.

Keeps forward-compatibility changes:
- EqualException.ForMismatchedValues string conversions
- xUnit1051 analyzer suppression
- GroupCollection comparison fix

Co-authored-by: agocke <515774+agocke@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 11, 2026

@copilot please revert the actual switch to the xunit.v3.assert package, but keep the changes needed to provide compatibility (except where they were made solely to adapt to assembly name).

Reverted in 9af3b69. All package references are back to the original Microsoft.DotNet.XUnitAssert/xunit.assert split. IL assembly extern name changes are also reverted. Kept the forward-compatibility changes: ForMismatchedValues string conversions, xUnit1051 suppression, and GroupCollectionTests2 collection comparison fix.

Copilot AI changed the title Migrate from Microsoft.DotNet.XUnitAssert/xunit.assert to xunit.v3.assert Prepare for xunit.v3.assert migration: forward-compatibility changes Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Infrastructure linkable-framework Issues associated with delivering a linker friendly framework

Projects

Status: No status
Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants