int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
+ if (other is null) return 1;
- if (!(other is ValueTuple))
+ if (other is not ValueTuple)
{
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
+ if (other is null) return 1;
- if (!(other is ValueTuple))
+ if (other is not ValueTuple)
{
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1> && Equals((ValueTuple<T1>)obj);
+ return obj is ValueTuple<T1> tuple && Equals(tuple);
}
/// <summary>
return EqualityComparer<T1>.Default.Equals(Item1, other.Item1);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1>)) return false;
-
- var objTuple = (ValueTuple<T1>)other;
-
- return comparer.Equals(Item1, objTuple.Item1);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1> vt &&
+ comparer.Equals(Item1, vt.Item1);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1> objTuple)
+ {
+ return Comparer<T1>.Default.Compare(Item1, objTuple.Item1);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- var objTuple = (ValueTuple<T1>)other;
-
- return Comparer<T1>.Default.Compare(Item1, objTuple.Item1);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1> objTuple)
+ {
+ return comparer.Compare(Item1, objTuple.Item1);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- var objTuple = (ValueTuple<T1>)other;
-
- return comparer.Compare(Item1, objTuple.Item1);
+ return 1;
}
/// <summary>
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2> && Equals((ValueTuple<T1, T2>)obj);
+ return obj is ValueTuple<T1, T2> tuple && Equals(tuple);
}
/// <summary>
/// <see cref="IEqualityComparer.Equals"/> implementation. If this method call returns <see langword="true"/>, the method is
/// called again and passed the <see cref="Item2"/> values of the two <see cref="ValueTuple{T1, T2}"/> instances.
/// </remarks>
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2>)) return false;
-
- var objTuple = (ValueTuple<T1, T2>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2>)other;
+ return comparer.Compare(Item2, objTuple.Item2);
+ }
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Item2, objTuple.Item2);
+ return 1;
}
/// <summary>
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2, T3> && Equals((ValueTuple<T1, T2, T3>)obj);
+ return obj is ValueTuple<T1, T2, T3> tuple && Equals(tuple);
}
/// <summary>
&& EqualityComparer<T3>.Default.Equals(Item3, other.Item3);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2, T3>)) return false;
-
- var objTuple = (ValueTuple<T1, T2, T3>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2)
- && comparer.Equals(Item3, objTuple.Item3);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2, T3> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2) &&
+ comparer.Equals(Item3, vt.Item3);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2, T3> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2, T3>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2, T3> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2, T3>)other;
+ c = comparer.Compare(Item2, objTuple.Item2);
+ if (c != 0) return c;
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ return comparer.Compare(Item3, objTuple.Item3);
+ }
- c = comparer.Compare(Item2, objTuple.Item2);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Item3, objTuple.Item3);
+ return 1;
}
/// <summary>
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2, T3, T4> && Equals((ValueTuple<T1, T2, T3, T4>)obj);
+ return obj is ValueTuple<T1, T2, T3, T4> tuple && Equals(tuple);
}
/// <summary>
&& EqualityComparer<T4>.Default.Equals(Item4, other.Item4);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2, T3, T4>)) return false;
-
- var objTuple = (ValueTuple<T1, T2, T3, T4>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2)
- && comparer.Equals(Item3, objTuple.Item3)
- && comparer.Equals(Item4, objTuple.Item4);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2, T3, T4> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2) &&
+ comparer.Equals(Item3, vt.Item3) &&
+ comparer.Equals(Item4, vt.Item4);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2, T3, T4> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2, T3, T4>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2, T3, T4> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2, T3, T4>)other;
+ c = comparer.Compare(Item2, objTuple.Item2);
+ if (c != 0) return c;
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ c = comparer.Compare(Item3, objTuple.Item3);
+ if (c != 0) return c;
- c = comparer.Compare(Item2, objTuple.Item2);
- if (c != 0) return c;
+ return comparer.Compare(Item4, objTuple.Item4);
+ }
- c = comparer.Compare(Item3, objTuple.Item3);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Item4, objTuple.Item4);
+ return 1;
}
/// <summary>
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2, T3, T4, T5> && Equals((ValueTuple<T1, T2, T3, T4, T5>)obj);
+ return obj is ValueTuple<T1, T2, T3, T4, T5> tuple && Equals(tuple);
}
/// <summary>
&& EqualityComparer<T5>.Default.Equals(Item5, other.Item5);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2, T3, T4, T5>)) return false;
-
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2)
- && comparer.Equals(Item3, objTuple.Item3)
- && comparer.Equals(Item4, objTuple.Item4)
- && comparer.Equals(Item5, objTuple.Item5);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2, T3, T4, T5> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2) &&
+ comparer.Equals(Item3, vt.Item3) &&
+ comparer.Equals(Item5, vt.Item5);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2, T3, T4, T5> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2, T3, T4, T5>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2, T3, T4, T5> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5>)other;
+ c = comparer.Compare(Item2, objTuple.Item2);
+ if (c != 0) return c;
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ c = comparer.Compare(Item3, objTuple.Item3);
+ if (c != 0) return c;
- c = comparer.Compare(Item2, objTuple.Item2);
- if (c != 0) return c;
+ c = comparer.Compare(Item4, objTuple.Item4);
+ if (c != 0) return c;
- c = comparer.Compare(Item3, objTuple.Item3);
- if (c != 0) return c;
+ return comparer.Compare(Item5, objTuple.Item5);
+ }
- c = comparer.Compare(Item4, objTuple.Item4);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Item5, objTuple.Item5);
+ return 1;
}
/// <summary>
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2, T3, T4, T5, T6> && Equals((ValueTuple<T1, T2, T3, T4, T5, T6>)obj);
+ return obj is ValueTuple<T1, T2, T3, T4, T5, T6> tuple && Equals(tuple);
}
/// <summary>
&& EqualityComparer<T6>.Default.Equals(Item6, other.Item6);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2, T3, T4, T5, T6>)) return false;
-
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5, T6>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2)
- && comparer.Equals(Item3, objTuple.Item3)
- && comparer.Equals(Item4, objTuple.Item4)
- && comparer.Equals(Item5, objTuple.Item5)
- && comparer.Equals(Item6, objTuple.Item6);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2, T3, T4, T5, T6> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2) &&
+ comparer.Equals(Item3, vt.Item3) &&
+ comparer.Equals(Item5, vt.Item5) &&
+ comparer.Equals(Item6, vt.Item6);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2, T3, T4, T5, T6> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2, T3, T4, T5, T6>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2, T3, T4, T5, T6> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5, T6>)other;
+ c = comparer.Compare(Item2, objTuple.Item2);
+ if (c != 0) return c;
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ c = comparer.Compare(Item3, objTuple.Item3);
+ if (c != 0) return c;
- c = comparer.Compare(Item2, objTuple.Item2);
- if (c != 0) return c;
+ c = comparer.Compare(Item4, objTuple.Item4);
+ if (c != 0) return c;
- c = comparer.Compare(Item3, objTuple.Item3);
- if (c != 0) return c;
+ c = comparer.Compare(Item5, objTuple.Item5);
+ if (c != 0) return c;
- c = comparer.Compare(Item4, objTuple.Item4);
- if (c != 0) return c;
+ return comparer.Compare(Item6, objTuple.Item6);
+ }
- c = comparer.Compare(Item5, objTuple.Item5);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Item6, objTuple.Item6);
+ return 1;
}
/// <summary>
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7> && Equals((ValueTuple<T1, T2, T3, T4, T5, T6, T7>)obj);
+ return obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7> tuple && Equals(tuple);
}
/// <summary>
&& EqualityComparer<T7>.Default.Equals(Item7, other.Item7);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7>)) return false;
-
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5, T6, T7>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2)
- && comparer.Equals(Item3, objTuple.Item3)
- && comparer.Equals(Item4, objTuple.Item4)
- && comparer.Equals(Item5, objTuple.Item5)
- && comparer.Equals(Item6, objTuple.Item6)
- && comparer.Equals(Item7, objTuple.Item7);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2, T3, T4, T5, T6, T7> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2) &&
+ comparer.Equals(Item3, vt.Item3) &&
+ comparer.Equals(Item5, vt.Item5) &&
+ comparer.Equals(Item6, vt.Item6) &&
+ comparer.Equals(Item7, vt.Item7);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2, T3, T4, T5, T6, T7> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2, T3, T4, T5, T6, T7>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2, T3, T4, T5, T6, T7> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5, T6, T7>)other;
+ c = comparer.Compare(Item2, objTuple.Item2);
+ if (c != 0) return c;
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ c = comparer.Compare(Item3, objTuple.Item3);
+ if (c != 0) return c;
- c = comparer.Compare(Item2, objTuple.Item2);
- if (c != 0) return c;
+ c = comparer.Compare(Item4, objTuple.Item4);
+ if (c != 0) return c;
- c = comparer.Compare(Item3, objTuple.Item3);
- if (c != 0) return c;
+ c = comparer.Compare(Item5, objTuple.Item5);
+ if (c != 0) return c;
- c = comparer.Compare(Item4, objTuple.Item4);
- if (c != 0) return c;
+ c = comparer.Compare(Item6, objTuple.Item6);
+ if (c != 0) return c;
- c = comparer.Compare(Item5, objTuple.Item5);
- if (c != 0) return c;
+ return comparer.Compare(Item7, objTuple.Item7);
+ }
- c = comparer.Compare(Item6, objTuple.Item6);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Item7, objTuple.Item7);
+ return 1;
}
/// <summary>
/// <param name="rest">The value of the tuple's eight component.</param>
public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest)
{
- if (!(rest is IValueTupleInternal))
+ if (rest is not IValueTupleInternal)
{
throw new ArgumentException(SR.ArgumentException_ValueTupleLastArgumentNotAValueTuple);
}
/// </remarks>
public override bool Equals(object? obj)
{
- return obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> && Equals((ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)obj);
+ return obj is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> tuple && Equals(tuple);
}
/// <summary>
&& EqualityComparer<TRest>.Default.Equals(Rest, other.Rest);
}
- bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer)
- {
- if (other == null || !(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)) return false;
-
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)other;
-
- return comparer.Equals(Item1, objTuple.Item1)
- && comparer.Equals(Item2, objTuple.Item2)
- && comparer.Equals(Item3, objTuple.Item3)
- && comparer.Equals(Item4, objTuple.Item4)
- && comparer.Equals(Item5, objTuple.Item5)
- && comparer.Equals(Item6, objTuple.Item6)
- && comparer.Equals(Item7, objTuple.Item7)
- && comparer.Equals(Rest, objTuple.Rest);
- }
+ bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) =>
+ other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> vt &&
+ comparer.Equals(Item1, vt.Item1) &&
+ comparer.Equals(Item2, vt.Item2) &&
+ comparer.Equals(Item3, vt.Item3) &&
+ comparer.Equals(Item5, vt.Item5) &&
+ comparer.Equals(Item6, vt.Item6) &&
+ comparer.Equals(Item7, vt.Item7) &&
+ comparer.Equals(Rest, vt.Rest);
int IComparable.CompareTo(object? other)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>))
+ if (other is not null)
{
+ if (other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> objTuple)
+ {
+ return CompareTo(objTuple);
+ }
+
ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
}
- return CompareTo((ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)other);
+ return 1;
}
/// <summary>Compares this instance to a specified instance and returns an indication of their relative values.</summary>
int IStructuralComparable.CompareTo(object? other, IComparer comparer)
{
- if (other == null) return 1;
-
- if (!(other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>))
+ if (other is not null)
{
- ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
- }
+ if (other is ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest> objTuple)
+ {
+ int c = comparer.Compare(Item1, objTuple.Item1);
+ if (c != 0) return c;
- var objTuple = (ValueTuple<T1, T2, T3, T4, T5, T6, T7, TRest>)other;
+ c = comparer.Compare(Item2, objTuple.Item2);
+ if (c != 0) return c;
- int c = comparer.Compare(Item1, objTuple.Item1);
- if (c != 0) return c;
+ c = comparer.Compare(Item3, objTuple.Item3);
+ if (c != 0) return c;
- c = comparer.Compare(Item2, objTuple.Item2);
- if (c != 0) return c;
+ c = comparer.Compare(Item4, objTuple.Item4);
+ if (c != 0) return c;
- c = comparer.Compare(Item3, objTuple.Item3);
- if (c != 0) return c;
+ c = comparer.Compare(Item5, objTuple.Item5);
+ if (c != 0) return c;
- c = comparer.Compare(Item4, objTuple.Item4);
- if (c != 0) return c;
+ c = comparer.Compare(Item6, objTuple.Item6);
+ if (c != 0) return c;
- c = comparer.Compare(Item5, objTuple.Item5);
- if (c != 0) return c;
+ c = comparer.Compare(Item7, objTuple.Item7);
+ if (c != 0) return c;
- c = comparer.Compare(Item6, objTuple.Item6);
- if (c != 0) return c;
+ return comparer.Compare(Rest, objTuple.Rest);
+ }
- c = comparer.Compare(Item7, objTuple.Item7);
- if (c != 0) return c;
+ ThrowHelper.ThrowArgumentException_TupleIncorrectType(this);
+ }
- return comparer.Compare(Rest, objTuple.Rest);
+ return 1;
}
/// <summary>
public override int GetHashCode()
{
// We want to have a limited hash in this case. We'll use the first 7 elements of the tuple
- if (!(Rest is IValueTupleInternal))
+ if (Rest is not IValueTupleInternal)
{
return HashCode.Combine(Item1?.GetHashCode() ?? 0,
Item2?.GetHashCode() ?? 0,
private int GetHashCodeCore(IEqualityComparer comparer)
{
// We want to have a limited hash in this case. We'll use the first 7 elements of the tuple
- if (!(Rest is IValueTupleInternal rest))
+ if (Rest is not IValueTupleInternal rest)
{
return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!), comparer.GetHashCode(Item3!),
comparer.GetHashCode(Item4!), comparer.GetHashCode(Item5!), comparer.GetHashCode(Item6!),