Skip to content

Conversation

@thomhurst
Copy link
Owner

Summary

  • Fixed xUnit migration code fixer generating incorrect method names for reference equality assertions
  • Changed IsSameReferenceIsSameReferenceAs and IsNotSameReferenceIsNotSameReferenceAs
  • Added tests for Assert.Same and Assert.NotSame conversion

Test plan

  • Added Assert_Same_Can_Be_Converted test
  • Added Assert_NotSame_Can_Be_Converted test
  • All existing xUnit migration tests pass (41/41)

Fixes #4333

🤖 Generated with Claude Code

The xUnit migration code fixer was generating IsSameReference and
IsNotSameReference, but the actual TUnit assertion methods are
IsSameReferenceAs and IsNotSameReferenceAs.

This fixes compilation errors (CS1061) when migrating xUnit tests
that use Assert.Same() or Assert.NotSame().

Fixes #4333

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@thomhurst
Copy link
Owner Author

Summary

Fixes xUnit migration code fixer to generate correct method names for reference equality assertions (IsSameReferenceAs and IsNotSameReferenceAs instead of non-existent IsSameReference/IsNotSameReference).

Critical Issues

None found ✅

Review Notes

Correctness Verified:

  • ✅ Method names now match actual TUnit API in TUnit.Assertions/Conditions/ReferenceEqualityAssertions.cs:10,47
  • ✅ Consistent with NUnit migration code fixer in TUnit.Analyzers.CodeFixers/NUnitMigrationCodeFixProvider.cs:919-920
  • ✅ Argument order preserved correctly (actual, expected) → Assert.That(actual).IsSameReferenceAs(expected)
  • ✅ Both Assert.Same and Assert.NotSame conversions tested with comprehensive test cases

TUnit Rules Compliance:

  • ✅ No source generator changes → snapshot tests not required
  • ✅ No public API changes → API snapshot tests not required
  • ✅ Changes only affect analyzers/code fixers → no dual-mode or reflection concerns
  • ✅ No VSTest usage, no performance hotpaths affected

Testing:
The new tests correctly verify:

  1. xUnit Assert.Same(expected, actual) → TUnit Assert.That(actual).IsSameReferenceAs(expected)
  2. xUnit Assert.NotSame(obj1, obj2) → TUnit Assert.That(obj2).IsNotSameReferenceAs(obj1)

Both tests properly validate the complete migration including [Fact][Test] and voidasync Task conversions.

Verdict

APPROVE - Clean fix that resolves issue #4333 with proper test coverage and no rule violations.

@thomhurst thomhurst merged commit 5790cbd into main Jan 12, 2026
13 checks passed
@thomhurst thomhurst deleted the fix/xunit-assert-same-method-name branch January 12, 2026 21:48
This was referenced Jan 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

xUnit Migration: Assert.Same converted to non-existent IsSameReference method

2 participants