Skip to content

[Feature]: [TUnit.Assertions.Should] BeEquivalentTo with a comparer is marked with RequiresUnreferencedCode. #5857

@kzrnm

Description

@kzrnm

Description

With Assert.That, specifying an IEqualityComparer makes it AOT-safe and suppresses the warning, but Should still produces the warning.

Expected Behavior

No IL2026

Actual Behavior

Raise IL2026

Steps to Reproduce

await Assert.That(new int[2]).IsEquivalentTo([0, 0]); // OK: IL2026
await Assert.That(new int[2]).IsEquivalentTo([0, 0], EqualityComparer<int>.Default); // OK: No warning
await new int[2].Should().BeEquivalentTo([0, 0]); // OK: IL2026
await new int[2].Should().BeEquivalentTo([0, 0], EqualityComparer<int>.Default); // NG: IL2026. 

TUnit Version

1.43.11

.NET Version

.NET 10

Operating System

Windows

IDE / Test Runner

dotnet CLI (dotnet test / dotnet run)

Error Output / Stack Trace

Additional Context

No response

IDE-Specific Issue?

  • I've confirmed this issue occurs when running via dotnet test or dotnet run, not just in my IDE

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions