Skip to content

xUnit migration reverses ProperSubset and ProperSuperset operands and loses strictness #7431

Closed

Description

@thomhurst

Summary

The xUnit migration code fix reverses the meaning of Assert.ProperSubset and Assert.ProperSuperset: it asserts against the expected set instead of the actual set. Passing tests can fail after migration. It also replaces strict set comparisons with non-strict comparisons even though TUnit already provides proper-subset and proper-superset assertions.

Reproduction

Apply the xUnit migration code fix to:

var subset = new HashSet<int> { 1, 2 };
var superset = new HashSet<int> { 1, 2, 3 };
Xunit.Assert.ProperSubset(superset, subset);
Xunit.Assert.ProperSuperset(subset, superset);

The generated assertions are Assert.That(superset).IsSubsetOf(subset) and Assert.That(subset).IsSupersetOf(superset), both of which fail.

Expected and actual

The migrated assertions should be Assert.That(subset).IsProperSubsetOf(superset) and Assert.That(superset).IsProperSupersetOf(subset). The actual output reverses the operands and adds a manual-conversion TODO instead of preserving strictness.

Evidence at commit d8badacb13f208819d39867ea384b9cdb746bfa4:

Acceptance criteria

  • Preserve actual/expected operand direction and strictness for both migration methods, using the existing proper-set assertions.
  • Update the two migration tests to expect correct assertions without the obsolete TODO.
  • Cover unequal sets that pass and equal sets that must fail, so validation checks behavior as well as generated text.
  • Run the relevant analyzer/code-fixer tests.

Environment

Repository main at d8badacb13f208819d39867ea384b9cdb746bfa4; confirmed by source inspection and existing code-fix fixtures, without executing tests.

Please preserve proper-set assertion semantics during xUnit migration.

Activity

  1. added
    P2Medium: edge case, mode divergence, flaky test, or workaround exists
    on Nov 3, 2026
  2. thomhurst commented on Nov 3, 2026

    @thomhurst
    OwnerAuthor

    Audited against main d87516cb9c: ConvertProperSubset and ConvertProperSuperset still use the first operand as the assertion subject and emit non-strict comparisons plus TODOs (lines 729–754). The issue and acceptance criteria remain current; no closing PR was found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Medium: edge case, mode divergence, flaky test, or workaround existsbugSomething isn't workingin-progressWork is in progress

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions