Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions TUnit.Assertions.Tests/Bugs/Issue5720Tests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Gated to match ImplicitConversionEqualityExtensions.cs — see issue #5765.
#if NET9_0_OR_GREATER
namespace TUnit.Assertions.Tests.Bugs;

/// <summary>
Expand Down Expand Up @@ -191,3 +193,5 @@ await Assert.That(assertionException.InnerException!.Message).StartsWith(
$"No implicit conversion operator from '{typeof(UnrelatedType)}' to '{typeof(string)}' was found.");
}
}

#endif
40 changes: 40 additions & 0 deletions TUnit.Assertions.Tests/Bugs/Issue5765Tests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Net;

namespace TUnit.Assertions.Tests.Bugs;

public class Issue5765Tests
{
[Test]
public async Task IsEqualTo_SameType_Enum()
{
var status = HttpStatusCode.OK;

await Assert.That(status).IsEqualTo(HttpStatusCode.OK);
}

[Test]
public async Task IsEqualTo_SameType_Primitive()
{
var value = 42;

await Assert.That(value).IsEqualTo(42);
}

[Test]
public async Task IsEqualTo_SameType_Record()
{
var point = new Point(1, 2);

await Assert.That(point).IsEqualTo(new Point(1, 2));
}

[Test]
public async Task IsNotEqualTo_SameType_Enum()
{
var status = HttpStatusCode.OK;

await Assert.That(status).IsNotEqualTo(HttpStatusCode.NotFound);
}

private sealed record Point(int X, int Y);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
// Gated to .NET 9+ because these overloads rely on [OverloadResolutionPriority] to
// lose to the source-generated single-generic IsEqualTo / IsNotEqualTo on same-type
// calls, and that attribute is silently dropped on net8.0 / netstandard2.0 (Polyfill
// does not supply it), causing CS0121. See issue #5765.
#if NET9_0_OR_GREATER
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
Expand Down Expand Up @@ -146,3 +151,4 @@ internal static class ImplicitConversionCache
return null;
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -3767,9 +3767,6 @@ namespace .Extensions
{
public static .<TValue> IsEqualTo<TValue>(this .<TValue> source, TValue? expected, [.("expected")] string? expectedExpression = null) { }
public static .<TValue> IsEqualTo<TValue>(this .<TValue> source, TValue? expected, .<TValue> comparer, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { }
[.("Looks up implicit conversion operators via reflection. Trimming may remove user-d" +
"efined operators.")]
public static .<TOther> IsEqualTo<TValue, TOther>(this .<TValue> source, TOther? expected, [.("expected")] string? expectedExpression = null) { }
}
public static class EquatableAssertionExtensions
{
Expand Down Expand Up @@ -4696,9 +4693,6 @@ namespace .Extensions
public static class NotEqualsAssertionExtensions
{
public static .<TValue> IsNotEqualTo<TValue>(this .<TValue> source, TValue notExpected, .<TValue>? comparer = null, [.("notExpected")] string? notExpectedExpression = null, [.("comparer")] string? comparerExpression = null) { }
[.("Looks up implicit conversion operators via reflection. Trimming may remove user-d" +
"efined operators.")]
public static .<TOther> IsNotEqualTo<TValue, TOther>(this .<TValue> source, TOther? notExpected, [.("notExpected")] string? notExpectedExpression = null) { }
}
public static class NotEquivalentToAssertionExtensions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3360,7 +3360,6 @@ namespace .Extensions
{
public static .<TValue> IsEqualTo<TValue>(this .<TValue> source, TValue? expected, [.("expected")] string? expectedExpression = null) { }
public static .<TValue> IsEqualTo<TValue>(this .<TValue> source, TValue? expected, .<TValue> comparer, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { }
public static .<TOther> IsEqualTo<TValue, TOther>(this .<TValue> source, TOther? expected, [.("expected")] string? expectedExpression = null) { }
}
public static class EquatableAssertionExtensions
{
Expand Down Expand Up @@ -4189,7 +4188,6 @@ namespace .Extensions
public static class NotEqualsAssertionExtensions
{
public static .<TValue> IsNotEqualTo<TValue>(this .<TValue> source, TValue notExpected, .<TValue>? comparer = null, [.("notExpected")] string? notExpectedExpression = null, [.("comparer")] string? comparerExpression = null) { }
public static .<TOther> IsNotEqualTo<TValue, TOther>(this .<TValue> source, TOther? notExpected, [.("notExpected")] string? notExpectedExpression = null) { }
}
public static class NotEquivalentToAssertionExtensions
{
Expand Down
Loading