diff --git a/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs b/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs index 240ad862ffcf2..87f5cd3897707 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs @@ -31,7 +31,7 @@ internal interface IValueTupleInternal : ITuple /// [Serializable] [TypeForwardedFrom("mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089")] - public struct ValueTuple + public readonly struct ValueTuple : IEquatable, IStructuralEquatable, IStructuralComparable, IComparable, IComparable, IValueTupleInternal, ITuple { /// @@ -290,7 +290,7 @@ public ValueTuple(T1 item1) /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -305,16 +305,16 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its field /// is equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple vt && comparer.Equals(Item1, vt.Item1); - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -337,12 +337,12 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { return Comparer.Default.Compare(Item1, other.Item1); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -366,12 +366,12 @@ public override int GetHashCode() return Item1?.GetHashCode() ?? 0; } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return comparer.GetHashCode(Item1!); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return comparer.GetHashCode(Item1!); } @@ -398,12 +398,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 1; + readonly int ITuple.Length => 1; /// /// Get the element at position . /// - object? ITuple.this[int index] + readonly object? ITuple.this[int index] { get { @@ -462,7 +462,7 @@ public ValueTuple(T1 item1, T2 item2) /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -476,7 +476,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2); @@ -500,12 +500,12 @@ public bool Equals(ValueTuple other) /// implementation. If this method call returns , the method is /// called again and passed the values of the two instances. /// - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple vt && comparer.Equals(Item1, vt.Item1) && comparer.Equals(Item2, vt.Item2); - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -528,7 +528,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -536,7 +536,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Item2, other.Item2); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -564,18 +564,18 @@ public override int GetHashCode() Item2?.GetHashCode() ?? 0); } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly int GetHashCodeCore(IEqualityComparer comparer) { return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!)); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -603,12 +603,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 2; + readonly int ITuple.Length => 2; /// /// Get the element at position . /// - object? ITuple.this[int index] => + readonly object? ITuple.this[int index] => index switch { 0 => Item1, @@ -668,7 +668,7 @@ public ValueTuple(T1 item1, T2 item2, T3 item3) /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -683,20 +683,20 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) && EqualityComparer.Default.Equals(Item3, other.Item3); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple vt && comparer.Equals(Item1, vt.Item1) && comparer.Equals(Item2, vt.Item2) && comparer.Equals(Item3, vt.Item3); - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -719,7 +719,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -730,7 +730,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Item3, other.Item3); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -762,19 +762,19 @@ public override int GetHashCode() Item3?.GetHashCode() ?? 0); } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly int GetHashCodeCore(IEqualityComparer comparer) { return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!), comparer.GetHashCode(Item3!)); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -800,12 +800,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 3; + readonly int ITuple.Length => 3; /// /// Get the element at position . /// - object? ITuple.this[int index] => + readonly object? ITuple.this[int index] => index switch { 0 => Item1, @@ -873,7 +873,7 @@ public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4) /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -888,7 +888,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) @@ -896,14 +896,14 @@ public bool Equals(ValueTuple other) && EqualityComparer.Default.Equals(Item4, other.Item4); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple 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) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -926,7 +926,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -940,7 +940,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Item4, other.Item4); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -976,12 +976,12 @@ public override int GetHashCode() Item4?.GetHashCode() ?? 0); } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly int GetHashCodeCore(IEqualityComparer comparer) { return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!), @@ -989,7 +989,7 @@ private int GetHashCodeCore(IEqualityComparer comparer) comparer.GetHashCode(Item4!)); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -1015,12 +1015,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 4; + readonly int ITuple.Length => 4; /// /// Get the element at position . /// - object? ITuple.this[int index] => + readonly object? ITuple.this[int index] => index switch { 0 => Item1, @@ -1096,7 +1096,7 @@ public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -1111,7 +1111,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) @@ -1120,14 +1120,14 @@ public bool Equals(ValueTuple other) && EqualityComparer.Default.Equals(Item5, other.Item5); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple 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) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -1150,7 +1150,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -1167,7 +1167,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Item5, other.Item5); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -1207,12 +1207,12 @@ public override int GetHashCode() Item5?.GetHashCode() ?? 0); } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly int GetHashCodeCore(IEqualityComparer comparer) { return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!), @@ -1221,7 +1221,7 @@ private int GetHashCodeCore(IEqualityComparer comparer) comparer.GetHashCode(Item5!)); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -1247,12 +1247,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 5; + readonly int ITuple.Length => 5; /// /// Get the element at position . /// - object? ITuple.this[int index] => + readonly object? ITuple.this[int index] => index switch { 0 => Item1, @@ -1336,7 +1336,7 @@ public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -1351,7 +1351,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) @@ -1361,7 +1361,7 @@ public bool Equals(ValueTuple other) && EqualityComparer.Default.Equals(Item6, other.Item6); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple vt && comparer.Equals(Item1, vt.Item1) && comparer.Equals(Item2, vt.Item2) && @@ -1369,7 +1369,7 @@ other is ValueTuple vt && comparer.Equals(Item5, vt.Item5) && comparer.Equals(Item6, vt.Item6); - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -1392,7 +1392,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -1412,7 +1412,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Item6, other.Item6); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -1456,12 +1456,12 @@ public override int GetHashCode() Item6?.GetHashCode() ?? 0); } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly int GetHashCodeCore(IEqualityComparer comparer) { return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!), @@ -1471,7 +1471,7 @@ private int GetHashCodeCore(IEqualityComparer comparer) comparer.GetHashCode(Item6!)); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -1497,12 +1497,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 6; + readonly int ITuple.Length => 6; /// /// Get the element at position . /// - object? ITuple.this[int index] => + readonly object? ITuple.this[int index] => index switch { 0 => Item1, @@ -1594,7 +1594,7 @@ public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -1609,7 +1609,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) @@ -1620,7 +1620,7 @@ public bool Equals(ValueTuple other) && EqualityComparer.Default.Equals(Item7, other.Item7); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple vt && comparer.Equals(Item1, vt.Item1) && comparer.Equals(Item2, vt.Item2) && @@ -1629,7 +1629,7 @@ other is ValueTuple vt && comparer.Equals(Item6, vt.Item6) && comparer.Equals(Item7, vt.Item7); - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -1652,7 +1652,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -1675,7 +1675,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Item7, other.Item7); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -1723,12 +1723,12 @@ public override int GetHashCode() Item7?.GetHashCode() ?? 0); } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly int GetHashCodeCore(IEqualityComparer comparer) { return HashCode.Combine(comparer.GetHashCode(Item1!), comparer.GetHashCode(Item2!), @@ -1739,7 +1739,7 @@ private int GetHashCodeCore(IEqualityComparer comparer) comparer.GetHashCode(Item7!)); } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -1765,12 +1765,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => 7; + readonly int ITuple.Length => 7; /// /// Get the element at position . /// - object? ITuple.this[int index] => + readonly object? ITuple.this[int index] => index switch { 0 => Item1, @@ -1876,7 +1876,7 @@ public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 /// Its components are equal to those of the current instance. Equality is determined by the default object equality comparer for each component. /// /// - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple tuple && Equals(tuple); } @@ -1891,7 +1891,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// The parameter is considered to be equal to the current instance if each of its fields /// are equal to that of the current instance, using the default comparer for that field's type. /// - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return EqualityComparer.Default.Equals(Item1, other.Item1) && EqualityComparer.Default.Equals(Item2, other.Item2) @@ -1903,7 +1903,7 @@ public bool Equals(ValueTuple other) && EqualityComparer.Default.Equals(Rest, other.Rest); } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) => other is ValueTuple vt && comparer.Equals(Item1, vt.Item1) && comparer.Equals(Item2, vt.Item2) && @@ -1913,7 +1913,7 @@ other is ValueTuple vt && comparer.Equals(Item7, vt.Item7) && comparer.Equals(Rest, vt.Rest); - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is not null) { @@ -1936,7 +1936,7 @@ int IComparable.CompareTo(object? other) /// instance is equal to , and greater than zero if this instance is greater /// than . /// - public int CompareTo(ValueTuple other) + public readonly int CompareTo(ValueTuple other) { int c = Comparer.Default.Compare(Item1, other.Item1); if (c != 0) return c; @@ -1962,7 +1962,7 @@ public int CompareTo(ValueTuple other) return Comparer.Default.Compare(Rest, other.Rest); } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is not null) { @@ -2076,12 +2076,12 @@ public override int GetHashCode() return -1; } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } - private int GetHashCodeCore(IEqualityComparer comparer) + private readonly 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 not IValueTupleInternal rest) @@ -2151,7 +2151,7 @@ private int GetHashCodeCore(IEqualityComparer comparer) return -1; } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return GetHashCodeCore(comparer); } @@ -2187,12 +2187,12 @@ string IValueTupleInternal.ToStringEnd() /// /// The number of positions in this data structure. /// - int ITuple.Length => Rest is IValueTupleInternal ? 7 + ((IValueTupleInternal)Rest).Length : 8; + readonly int ITuple.Length => Rest is IValueTupleInternal ? 7 + ((IValueTupleInternal)Rest).Length : 8; /// /// Get the element at position . /// - object? ITuple.this[int index] + readonly object? ITuple.this[int index] { get { diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 900040db349ef..1b4994a2ec51a 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -7113,7 +7113,7 @@ public UnhandledExceptionEventArgs(object exception, bool isTerminating) { } public bool IsTerminating { get { throw null; } } } public delegate void UnhandledExceptionEventHandler(object sender, System.UnhandledExceptionEventArgs e); - public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable, System.IEquatable, System.Runtime.CompilerServices.ITuple + public readonly partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable, System.IEquatable, System.Runtime.CompilerServices.ITuple { object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } @@ -7140,16 +7140,16 @@ public partial struct ValueTuple : System.Collections.IStructuralComparable, { public T1 Item1; public ValueTuple(T1 item1) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo(System.ValueTuple other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals(System.ValueTuple other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo(System.ValueTuple other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals(System.ValueTuple other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable<(T1, T2)>, System.IEquatable<(T1, T2)>, System.Runtime.CompilerServices.ITuple @@ -7157,16 +7157,16 @@ public partial struct ValueTuple : System.Collections.IStructuralCompara public T1 Item1; public T2 Item2; public ValueTuple(T1 item1, T2 item2) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo((T1, T2) other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals((T1, T2) other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo((T1, T2) other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals((T1, T2) other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable<(T1, T2, T3)>, System.IEquatable<(T1, T2, T3)>, System.Runtime.CompilerServices.ITuple @@ -7175,16 +7175,16 @@ public partial struct ValueTuple : System.Collections.IStructuralCom public T2 Item2; public T3 Item3; public ValueTuple(T1 item1, T2 item2, T3 item3) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo((T1, T2, T3) other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals((T1, T2, T3) other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo((T1, T2, T3) other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals((T1, T2, T3) other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable<(T1, T2, T3, T4)>, System.IEquatable<(T1, T2, T3, T4)>, System.Runtime.CompilerServices.ITuple @@ -7194,16 +7194,16 @@ public partial struct ValueTuple : System.Collections.IStructura public T3 Item3; public T4 Item4; public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo((T1, T2, T3, T4) other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals((T1, T2, T3, T4) other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo((T1, T2, T3, T4) other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals((T1, T2, T3, T4) other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable<(T1, T2, T3, T4, T5)>, System.IEquatable<(T1, T2, T3, T4, T5)>, System.Runtime.CompilerServices.ITuple @@ -7214,16 +7214,16 @@ public partial struct ValueTuple : System.Collections.IStruc public T4 Item4; public T5 Item5; public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo((T1, T2, T3, T4, T5) other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals((T1, T2, T3, T4, T5) other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo((T1, T2, T3, T4, T5) other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals((T1, T2, T3, T4, T5) other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable<(T1, T2, T3, T4, T5, T6)>, System.IEquatable<(T1, T2, T3, T4, T5, T6)>, System.Runtime.CompilerServices.ITuple @@ -7235,16 +7235,16 @@ public partial struct ValueTuple : System.Collections.IS public T5 Item5; public T6 Item6; public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo((T1, T2, T3, T4, T5, T6) other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals((T1, T2, T3, T4, T5, T6) other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo((T1, T2, T3, T4, T5, T6) other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals((T1, T2, T3, T4, T5, T6) other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable<(T1, T2, T3, T4, T5, T6, T7)>, System.IEquatable<(T1, T2, T3, T4, T5, T6, T7)>, System.Runtime.CompilerServices.ITuple @@ -7257,16 +7257,16 @@ public partial struct ValueTuple : System.Collection public T6 Item6; public T7 Item7; public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo((T1, T2, T3, T4, T5, T6, T7) other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals((T1, T2, T3, T4, T5, T6, T7) other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo((T1, T2, T3, T4, T5, T6, T7) other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals((T1, T2, T3, T4, T5, T6, T7) other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable>, System.IEquatable>, System.Runtime.CompilerServices.ITuple where TRest : struct @@ -7280,16 +7280,16 @@ public partial struct ValueTuple : System.Col public T7 Item7; public TRest Rest; public ValueTuple(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, TRest rest) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } - int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } - public int CompareTo(System.ValueTuple other) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public bool Equals(System.ValueTuple other) { throw null; } + readonly object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly int System.Runtime.CompilerServices.ITuple.Length { get { throw null; } } + public readonly int CompareTo(System.ValueTuple other) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } + public readonly bool Equals(System.ValueTuple other) { throw null; } public override int GetHashCode() { throw null; } - int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } - bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } - int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } - int System.IComparable.CompareTo(object? other) { throw null; } + readonly int System.Collections.IStructuralComparable.CompareTo(object? other, System.Collections.IComparer comparer) { throw null; } + readonly bool System.Collections.IStructuralEquatable.Equals(object? other, System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.Collections.IStructuralEquatable.GetHashCode(System.Collections.IEqualityComparer comparer) { throw null; } + readonly int System.IComparable.CompareTo(object? other) { throw null; } public override string ToString() { throw null; } } public abstract partial class ValueType