ValueTupleComparer
Comparator for two ValueTuples.
using NUnit.Framework.Internal;
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints.Comparers
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal static class ValueTupleComparer
{
private static bool IsCorrectType(Type type)
{
return TypeHelper.IsValueTuple(type);
}
[return: System.Runtime.CompilerServices.Nullable(2)]
private static object GetValue(Type type, string propertyName, object obj)
{
return type.GetField(propertyName)?.GetValue(obj);
}
public static EqualMethodResult Equal(object x, object y, ref Tolerance tolerance, ComparisonState state, NUnitEqualityComparer equalityComparer)
{
return TupleComparerBase.Equal(x, y, ref tolerance, state, equalityComparer, IsCorrectType, GetValue);
}
}
}