From a8302877abd878e2f9d41a5454aaaf3bc6370599 Mon Sep 17 00:00:00 2001 From: Vlad Date: Wed, 6 Jan 2021 14:46:17 +0300 Subject: [PATCH 1/3] Small annotation part for pr init --- .../src/CallSiteJsonFormatter.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/libraries/Microsoft.Extensions.DependencyInjection/src/CallSiteJsonFormatter.cs b/src/libraries/Microsoft.Extensions.DependencyInjection/src/CallSiteJsonFormatter.cs index bf39993860f14..bac07ac4dcd5c 100644 --- a/src/libraries/Microsoft.Extensions.DependencyInjection/src/CallSiteJsonFormatter.cs +++ b/src/libraries/Microsoft.Extensions.DependencyInjection/src/CallSiteJsonFormatter.cs @@ -130,12 +130,12 @@ public CallSiteFormatterContext(StringBuilder builder, int offset, HashSet Date: Mon, 26 Apr 2021 11:13:25 +0300 Subject: [PATCH 2/3] remaining changes --- .../Common/src/Interop/Unix/Interop.Errors.cs | 2 +- .../Interop.GssBuffer.cs | 6 +- .../Windows/Advapi32/Interop.PERF_INFO.cs | 2 +- .../Windows/Crypt32/Interop.CRYPT_BIT_BLOB.cs | 2 +- .../Windows/Crypt32/Interop.FindOidInfo.cs | 4 +- .../src/Interop/Windows/Gdi32/Interop.RECT.cs | 2 +- .../Interop/Windows/Interop.LongFileTime.cs | 2 +- .../IpHlpApi/Interop.NetworkInformation.cs | 2 +- .../Windows/Kernel32/Interop.FILE_TIME.cs | 6 +- .../Windows/Kernel32/Interop.TimeZone.cs | 8 +- .../Interop.FILE_FULL_DIR_INFORMATION.cs | 2 +- .../Interop/Windows/Ole32/Interop.STATSTG.cs | 2 +- .../Interop/Windows/SspiCli/Interop.SSPI.cs | 4 +- .../Common/src/System/MutableDecimal.cs | 4 +- .../System/Runtime/InteropServices/Variant.cs | 50 ++-- .../src/System/Text/ValueStringBuilder.cs | 16 +- .../ref/Microsoft.Bcl.AsyncInterfaces.cs | 6 +- .../Sources/ManualResetValueTaskSourceCore.cs | 12 +- .../ObjectModel/ReadOnlyDictionary.cs | 8 +- .../src/System/Collections/DictionaryEntry.cs | 6 +- .../src/System/Decimal.DecCalc.cs | 24 +- .../src/System/Globalization/DateTimeParse.cs | 18 +- .../System/Globalization/TimeSpanFormat.cs | 12 +- .../src/System/Globalization/TimeSpanParse.cs | 22 +- .../src/System/HashCode.cs | 2 +- .../src/System/Nullable.cs | 6 +- .../AsyncVoidMethodBuilder.cs | 4 +- .../Runtime/InteropServices/GCHandle.cs | 8 +- .../src/System/Text/SpanRuneEnumerator.cs | 4 +- .../src/System/Text/StringBuilder.cs | 4 +- .../src/System/Text/StringRuneEnumerator.cs | 8 +- .../Text/Unicode/TextSegmentationUtility.cs | 4 +- .../Sources/ManualResetValueTaskSourceCore.cs | 14 +- .../src/System/ValueTuple.cs | 230 +++++++++--------- .../Serialization/CollectionDataContract.cs | 8 +- .../Serialization/DateTimeOffsetAdapter.cs | 6 +- .../Serialization/ObjectReferenceStack.cs | 2 +- .../Runtime/Serialization/ScopedKnownTypes.cs | 2 +- .../src/System/Text/SurrogateChar.cs | 6 +- .../QueryResult.Enumerator.cs | 2 +- .../Runtime/BindingFlagSupport/QueryResult.cs | 6 +- .../Reflection/Runtime/General/ListBuilder.cs | 4 +- .../System.Runtime/ref/System.Runtime.cs | 220 ++++++++--------- 43 files changed, 381 insertions(+), 381 deletions(-) diff --git a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs index 4e9b16098dcad..588e45503adaa 100644 --- a/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs +++ b/src/libraries/Common/src/Interop/Unix/Interop.Errors.cs @@ -130,7 +130,7 @@ internal ErrorInfo(Error error) _rawErrno = -1; } - internal Error Error + internal readonly Error Error { get { return _error; } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.GssBuffer.cs b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.GssBuffer.cs index a2c6255541e28..b64fa4e7e52f6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.GssBuffer.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Net.Security.Native/Interop.GssBuffer.cs @@ -16,7 +16,7 @@ internal struct GssBuffer : IDisposable internal ulong _length; internal IntPtr _data; - internal int Copy(byte[] destination, int offset) + internal readonly int Copy(byte[] destination, int offset) { Debug.Assert(destination != null, "target destination cannot be null"); Debug.Assert((offset >= 0 && offset < destination.Length) || destination.Length == 0, "invalid offset " + offset); @@ -38,7 +38,7 @@ internal int Copy(byte[] destination, int offset) return sourceLength; } - internal byte[] ToByteArray() + internal readonly byte[] ToByteArray() { if (_data == IntPtr.Zero || _length == 0) { @@ -51,7 +51,7 @@ internal byte[] ToByteArray() return destination; } - internal unsafe ReadOnlySpan Span => (_data != IntPtr.Zero && _length != 0) ? + internal unsafe readonly ReadOnlySpan Span => (_data != IntPtr.Zero && _length != 0) ? new ReadOnlySpan(_data.ToPointer(), checked((int)_length)) : default; diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs index 2d65e77e2a215..2aa2ed5be7cde 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.PERF_INFO.cs @@ -97,7 +97,7 @@ internal struct SYSTEMTIME internal short wSecond; internal short wMilliseconds; - public override string ToString() + public override readonly string ToString() { return "[SYSTEMTIME: " + wDay.ToString(CultureInfo.CurrentCulture) + "/" + wMonth.ToString(CultureInfo.CurrentCulture) + "/" + wYear.ToString(CultureInfo.CurrentCulture) diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CRYPT_BIT_BLOB.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CRYPT_BIT_BLOB.cs index 77620c7734bb1..aba78032c5529 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CRYPT_BIT_BLOB.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CRYPT_BIT_BLOB.cs @@ -15,7 +15,7 @@ internal struct CRYPT_BIT_BLOB internal IntPtr pbData; internal int cUnusedBits; - internal byte[] ToByteArray() + internal readonly byte[] ToByteArray() { int numBytes = cbData; byte[] data = new byte[numBytes]; diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs index 3df34615836a6..358af92296b80 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.FindOidInfo.cs @@ -21,7 +21,7 @@ internal struct CRYPT_OID_INFO public int cbData; public IntPtr pbData; - public string? OID + public readonly string? OID { get { @@ -29,7 +29,7 @@ public string? OID } } - public string? Name + public readonly string? Name { get { diff --git a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.RECT.cs b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.RECT.cs index fdd5de32a0e5c..a176cc3cb2645 100644 --- a/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.RECT.cs +++ b/src/libraries/Common/src/Interop/Windows/Gdi32/Interop.RECT.cs @@ -16,7 +16,7 @@ public struct RECT public int right; public int bottom; - public Size Size => new Size(right - left, bottom - top); + public readonly Size Size => new Size(right - left, bottom - top); } } } diff --git a/src/libraries/Common/src/Interop/Windows/Interop.LongFileTime.cs b/src/libraries/Common/src/Interop/Windows/Interop.LongFileTime.cs index e1be498ffe697..8a49039323bcf 100644 --- a/src/libraries/Common/src/Interop/Windows/Interop.LongFileTime.cs +++ b/src/libraries/Common/src/Interop/Windows/Interop.LongFileTime.cs @@ -22,6 +22,6 @@ internal struct LongFileTime internal long TicksSince1601; #pragma warning restore CS0649 - internal DateTimeOffset ToDateTimeOffset() => new DateTimeOffset(DateTime.FromFileTimeUtc(TicksSince1601)); + internal readonly DateTimeOffset ToDateTimeOffset() => new DateTimeOffset(DateTime.FromFileTimeUtc(TicksSince1601)); } } diff --git a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs index 81faff1d9a04a..da71c9b507cb2 100644 --- a/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/IpHlpApi/Interop.NetworkInformation.cs @@ -58,7 +58,7 @@ internal struct IpSocketAddress internal IntPtr address; internal int addressLength; - internal IPAddress MarshalIPAddress() + internal readonly IPAddress MarshalIPAddress() { // Determine the address family used to create the IPAddress. AddressFamily family = (addressLength > Internals.SocketAddress.IPv4AddressSize) diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FILE_TIME.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FILE_TIME.cs index 19044dc625017..94912ba81d9f0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FILE_TIME.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FILE_TIME.cs @@ -18,9 +18,9 @@ internal FILE_TIME(long fileTime) dwHighDateTime = (uint)(fileTime >> 32); } - internal long ToTicks() => ((long)dwHighDateTime << 32) + dwLowDateTime; - internal DateTime ToDateTimeUtc() => DateTime.FromFileTimeUtc(ToTicks()); - internal DateTimeOffset ToDateTimeOffset() => DateTimeOffset.FromFileTime(ToTicks()); + internal readonly long ToTicks() => ((long)dwHighDateTime << 32) + dwLowDateTime; + internal readonly DateTime ToDateTimeUtc() => DateTime.FromFileTimeUtc(ToTicks()); + internal readonly DateTimeOffset ToDateTimeOffset() => DateTimeOffset.FromFileTime(ToTicks()); } } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs index 3ed47085af6c0..6f7dba9caee8d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs @@ -18,7 +18,7 @@ internal struct SYSTEMTIME internal ushort Second; internal ushort Milliseconds; - internal bool Equals(in SYSTEMTIME other) => + internal readonly bool Equals(in SYSTEMTIME other) => Year == other.Year && Month == other.Month && DayOfWeek == other.DayOfWeek && @@ -42,7 +42,7 @@ internal unsafe struct TIME_DYNAMIC_ZONE_INFORMATION internal fixed char TimeZoneKeyName[128]; internal byte DynamicDaylightTimeDisabled; - internal string GetTimeZoneKeyName() + internal readonly string GetTimeZoneKeyName() { fixed (char* p = TimeZoneKeyName) return new string(p); @@ -68,13 +68,13 @@ internal TIME_ZONE_INFORMATION(in TIME_DYNAMIC_ZONE_INFORMATION dtzi) *pTo = *(TIME_ZONE_INFORMATION*)pFrom; } - internal string GetStandardName() + internal readonly string GetStandardName() { fixed (char* p = StandardName) return new string(p); } - internal string GetDaylightName() + internal readonly string GetDaylightName() { fixed (char* p = DaylightName) return new string(p); diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.FILE_FULL_DIR_INFORMATION.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.FILE_FULL_DIR_INFORMATION.cs index ea1365e844e8c..998f4b8313f48 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.FILE_FULL_DIR_INFORMATION.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.FILE_FULL_DIR_INFORMATION.cs @@ -54,7 +54,7 @@ public struct FILE_FULL_DIR_INFORMATION public uint EaSize; private char _fileName; - public unsafe ReadOnlySpan FileName { get { fixed (char* c = &_fileName) { return new ReadOnlySpan(c, (int)FileNameLength / sizeof(char)); } } } + public unsafe readonly ReadOnlySpan FileName { get { fixed (char* c = &_fileName) { return new ReadOnlySpan(c, (int)FileNameLength / sizeof(char)); } } } /// /// Gets the next info pointer or null if there are no more. diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs index c59b2ea638cee..6c25299e42507 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.STATSTG.cs @@ -59,7 +59,7 @@ internal struct STATSTG public uint grfStateBits; public uint reserved; - public string? GetName() => Marshal.PtrToStringUni(pwcsName); + public readonly string? GetName() => Marshal.PtrToStringUni(pwcsName); /// /// Caller is responsible for freeing the name memory. diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs index b675f7f022473..c47afd0a94b33 100644 --- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs +++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs @@ -23,7 +23,7 @@ internal struct CredHandle private IntPtr dwLower; private IntPtr dwUpper; - public bool IsZero + public readonly bool IsZero { [MethodImpl(MethodImplOptions.AggressiveInlining)] get @@ -38,7 +38,7 @@ internal void SetToInvalid() dwUpper = IntPtr.Zero; } - public override string ToString() + public override readonly string ToString() { { return dwLower.ToString("x") + ":" + dwUpper.ToString("x"); } } diff --git a/src/libraries/Common/src/System/MutableDecimal.cs b/src/libraries/Common/src/System/MutableDecimal.cs index ab40e9d4c158f..d1e1d588e5a4c 100644 --- a/src/libraries/Common/src/System/MutableDecimal.cs +++ b/src/libraries/Common/src/System/MutableDecimal.cs @@ -23,13 +23,13 @@ internal struct MutableDecimal public bool IsNegative { - get { return (Flags & SignMask) != 0; } + readonly get { return (Flags & SignMask) != 0; } set { Flags = (Flags & ~SignMask) | (value ? SignMask : 0); } } public int Scale { - get { return (byte)(Flags >> ScaleShift); } + readonly get { return (byte)(Flags >> ScaleShift); } set { Flags = (Flags & ~ScaleMask) | ((uint)value << ScaleShift); } } diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/Variant.cs b/src/libraries/Common/src/System/Runtime/InteropServices/Variant.cs index c0eb0c6b819b6..f351de07e4c94 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/Variant.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/Variant.cs @@ -230,7 +230,7 @@ public unsafe void CopyFromIndirect(object value) /// Get the managed object representing the Variant. /// /// - public object? ToObject() + public readonly object? ToObject() { // Check the simple case upfront if (IsEmpty) @@ -316,13 +316,13 @@ public void Clear() public VarEnum VariantType { - get => (VarEnum)_typeUnion._vt; + readonly get => (VarEnum)_typeUnion._vt; set => _typeUnion._vt = (ushort)value; } - public bool IsEmpty => _typeUnion._vt == ((ushort)VarEnum.VT_EMPTY); + public readonly bool IsEmpty => _typeUnion._vt == ((ushort)VarEnum.VT_EMPTY); - public bool IsByRef => (_typeUnion._vt & ((ushort)VarEnum.VT_BYREF)) != 0; + public readonly bool IsByRef => (_typeUnion._vt & ((ushort)VarEnum.VT_BYREF)) != 0; public void SetAsNULL() { @@ -334,7 +334,7 @@ public void SetAsNULL() public sbyte AsI1 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_I1); return _typeUnion._unionTypes._i1; @@ -351,7 +351,7 @@ public sbyte AsI1 public short AsI2 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_I2); return _typeUnion._unionTypes._i2; @@ -368,7 +368,7 @@ public short AsI2 public int AsI4 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_I4); return _typeUnion._unionTypes._i4; @@ -385,7 +385,7 @@ public int AsI4 public long AsI8 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_I8); return _typeUnion._unionTypes._i8; @@ -402,7 +402,7 @@ public long AsI8 public byte AsUi1 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_UI1); return _typeUnion._unionTypes._ui1; @@ -419,7 +419,7 @@ public byte AsUi1 public ushort AsUi2 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_UI2); return _typeUnion._unionTypes._ui2; @@ -436,7 +436,7 @@ public ushort AsUi2 public uint AsUi4 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_UI4); return _typeUnion._unionTypes._ui4; @@ -453,7 +453,7 @@ public uint AsUi4 public ulong AsUi8 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_UI8); return _typeUnion._unionTypes._ui8; @@ -470,7 +470,7 @@ public ulong AsUi8 public int AsInt { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_INT); return _typeUnion._unionTypes._int; @@ -487,7 +487,7 @@ public int AsInt public uint AsUint { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_UINT); return _typeUnion._unionTypes._uint; @@ -504,7 +504,7 @@ public uint AsUint public bool AsBool { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_BOOL); return _typeUnion._unionTypes._bool != 0; @@ -523,7 +523,7 @@ public bool AsBool public int AsError { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_ERROR); return _typeUnion._unionTypes._error; @@ -540,7 +540,7 @@ public int AsError public float AsR4 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_R4); return _typeUnion._unionTypes._r4; @@ -557,7 +557,7 @@ public float AsR4 public double AsR8 { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_R8); return _typeUnion._unionTypes._r8; @@ -574,7 +574,7 @@ public double AsR8 public decimal AsDecimal { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_DECIMAL); // The first byte of Decimal is unused, but usually set to 0 @@ -596,7 +596,7 @@ public decimal AsDecimal public decimal AsCy { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_CY); return decimal.FromOACurrency(_typeUnion._unionTypes._cy); @@ -613,7 +613,7 @@ public decimal AsCy public DateTime AsDate { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_DATE); return DateTime.FromOADate(_typeUnion._unionTypes._date); @@ -630,7 +630,7 @@ public DateTime AsDate public string AsBstr { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_BSTR); return (string)Marshal.PtrToStringBSTR(this._typeUnion._unionTypes._bstr); @@ -647,7 +647,7 @@ public string AsBstr public object? AsUnknown { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_UNKNOWN); if (_typeUnion._unionTypes._unknown == IntPtr.Zero) @@ -675,7 +675,7 @@ public object? AsUnknown public object? AsDispatch { - get + readonly get { Debug.Assert(VariantType == VarEnum.VT_DISPATCH); if (_typeUnion._unionTypes._dispatch == IntPtr.Zero) @@ -699,7 +699,7 @@ public object? AsDispatch } } - public IntPtr AsByRefVariant + public readonly IntPtr AsByRefVariant { get { diff --git a/src/libraries/Common/src/System/Text/ValueStringBuilder.cs b/src/libraries/Common/src/System/Text/ValueStringBuilder.cs index c4c4ea1ba478d..9f5be3022fc38 100644 --- a/src/libraries/Common/src/System/Text/ValueStringBuilder.cs +++ b/src/libraries/Common/src/System/Text/ValueStringBuilder.cs @@ -30,7 +30,7 @@ public ValueStringBuilder(int initialCapacity) public int Length { - get => _pos; + readonly get => _pos; set { Debug.Assert(value >= 0); @@ -39,7 +39,7 @@ public int Length } } - public int Capacity => _chars.Length; + public readonly int Capacity => _chars.Length; public void EnsureCapacity(int capacity) { @@ -57,7 +57,7 @@ public void EnsureCapacity(int capacity) /// This overload is pattern matched in the C# 7.3+ compiler so you can omit /// the explicit method call, and write eg "fixed (char* c = builder)" /// - public ref char GetPinnableReference() + public readonly ref char GetPinnableReference() { return ref MemoryMarshal.GetReference(_chars); } @@ -76,7 +76,7 @@ public ref char GetPinnableReference(bool terminate) return ref MemoryMarshal.GetReference(_chars); } - public ref char this[int index] + public readonly ref char this[int index] { get { @@ -93,7 +93,7 @@ public override string ToString() } /// Returns the underlying storage of the builder. - public Span RawChars => _chars; + public readonly Span RawChars => _chars; /// /// Returns a span around the contents of the builder. @@ -109,9 +109,9 @@ public ReadOnlySpan AsSpan(bool terminate) return _chars.Slice(0, _pos); } - public ReadOnlySpan AsSpan() => _chars.Slice(0, _pos); - public ReadOnlySpan AsSpan(int start) => _chars.Slice(start, _pos - start); - public ReadOnlySpan AsSpan(int start, int length) => _chars.Slice(start, length); + public readonly ReadOnlySpan AsSpan() => _chars.Slice(0, _pos); + public readonly ReadOnlySpan AsSpan(int start) => _chars.Slice(start, _pos - start); + public readonly ReadOnlySpan AsSpan(int start, int length) => _chars.Slice(start, length); public bool TryCopyTo(Span destination, out int charsWritten) { diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs index 13bb163974c96..4d1d8097fc18a 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs @@ -85,9 +85,9 @@ public partial struct ManualResetValueTaskSourceCore private object _dummy; private int _dummyPrimitive; public bool RunContinuationsAsynchronously { readonly get { throw null; } set { } } - public short Version { get { throw null; } } - public TResult GetResult(short token) { throw null; } - public System.Threading.Tasks.Sources.ValueTaskSourceStatus GetStatus(short token) { throw null; } + public readonly short Version { get { throw null; } } + public readonly TResult GetResult(short token) { throw null; } + public readonly System.Threading.Tasks.Sources.ValueTaskSourceStatus GetStatus(short token) { throw null; } public void OnCompleted(System.Action continuation, object state, short token, System.Threading.Tasks.Sources.ValueTaskSourceOnCompletedFlags flags) { } public void Reset() { } public void SetException(System.Exception error) { } diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs index 3cb6e817aa614..8d6553e53b6f3 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs @@ -47,7 +47,7 @@ public struct ManualResetValueTaskSourceCore /// Gets or sets whether to force continuations to run asynchronously. /// Continuations may run asynchronously if this is false, but they'll never run synchronously if this is true. - public bool RunContinuationsAsynchronously { get; set; } + public bool RunContinuationsAsynchronously { readonly get; set; } /// Resets to prepare for the next operation. public void Reset() @@ -80,11 +80,11 @@ public void SetException(Exception error) } /// Gets the operation version. - public short Version => _version; + public readonly short Version => _version; /// Gets the status of the operation. /// Opaque value that was provided to the 's constructor. - public ValueTaskSourceStatus GetStatus(short token) + public readonly ValueTaskSourceStatus GetStatus(short token) { ValidateToken(token); return @@ -96,7 +96,7 @@ public ValueTaskSourceStatus GetStatus(short token) /// Gets the result of the operation. /// Opaque value that was provided to the 's constructor. - public TResult GetResult(short token) + public readonly TResult GetResult(short token) { ValidateToken(token); if (!_completed) @@ -189,7 +189,7 @@ public void OnCompleted(Action continuation, object state, short token, /// Ensures that the specified token matches the current version. /// The token supplied by . - private void ValidateToken(short token) + private readonly void ValidateToken(short token) { if (token != _version) { @@ -227,7 +227,7 @@ private void SignalCompletion() /// This assumes that if is not null we're already /// running within that . /// - private void InvokeContinuation() + private readonly void InvokeContinuation() { Debug.Assert(_continuation != null); diff --git a/src/libraries/System.ObjectModel/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs b/src/libraries/System.ObjectModel/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs index 28b4c06533fa1..fed8ef009e866 100644 --- a/src/libraries/System.ObjectModel/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs +++ b/src/libraries/System.ObjectModel/src/System/Collections/ObjectModel/ReadOnlyDictionary.cs @@ -247,16 +247,16 @@ public DictionaryEnumerator(IDictionary dictionary) _enumerator = _dictionary.GetEnumerator(); } - public DictionaryEntry Entry + public readonly DictionaryEntry Entry { get => new DictionaryEntry(_enumerator.Current.Key, _enumerator.Current.Value); } - public object Key => _enumerator.Current.Key; + public readonly object Key => _enumerator.Current.Key; - public object? Value => _enumerator.Current.Value; + public readonly object? Value => _enumerator.Current.Value; - public object Current => Entry; + public readonly object Current => Entry; public bool MoveNext() => _enumerator.MoveNext(); diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/DictionaryEntry.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/DictionaryEntry.cs index 700835bc0790d..96813c4a0864e 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/DictionaryEntry.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/DictionaryEntry.cs @@ -24,18 +24,18 @@ public DictionaryEntry(object key, object? value) public object Key { - get => _key; + readonly get => _key; set => _key = value; } public object? Value { - get => _value; + readonly get => _value; set => _value = value; } [EditorBrowsable(EditorBrowsableState.Never)] - public void Deconstruct(out object key, out object? value) + public readonly void Deconstruct(out object key, out object? value) { key = Key; value = Value; diff --git a/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs b/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs index d56ce8ebb7fc7..7da1074db8214 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs @@ -13,15 +13,15 @@ namespace System public partial struct Decimal { // Low level accessors used by a DecCalc and formatting - internal uint High => _hi32; - internal uint Low => (uint)_lo64; - internal uint Mid => (uint)(_lo64 >> 32); + internal readonly uint High => _hi32; + internal readonly uint Low => (uint)_lo64; + internal readonly uint Mid => (uint)(_lo64 >> 32); - internal bool IsNegative => _flags < 0; + internal readonly bool IsNegative => _flags < 0; - internal int Scale => (byte)(_flags >> ScaleShift); + internal readonly int Scale => (byte)(_flags >> ScaleShift); - private ulong Low64 => _lo64; + private readonly ulong Low64 => _lo64; private static ref DecCalc AsMutable(ref decimal d) => ref Unsafe.As(ref d); @@ -65,29 +65,29 @@ private struct DecCalc private uint High { - get => uhi; + readonly get => uhi; set => uhi = value; } private uint Low { - get => ulo; + readonly get => ulo; set => ulo = value; } private uint Mid { - get => umid; + readonly get => umid; set => umid = value; } - private bool IsNegative => (int)uflags < 0; + private readonly bool IsNegative => (int)uflags < 0; - private int Scale => (byte)(uflags >> ScaleShift); + private readonly int Scale => (byte)(uflags >> ScaleShift); private ulong Low64 { - get => ulomid; + readonly get => ulomid; set => ulomid = value; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs index 75c5b0bf52e80..dbb005b6c6b45 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/DateTimeParse.cs @@ -5243,7 +5243,7 @@ internal ref struct __DTString internal int Index; // The length of Value string. - internal int Length => Value.Length; + internal readonly int Length => Value.Length; // The current character to be looked at. internal char m_current; @@ -5270,7 +5270,7 @@ internal __DTString(ReadOnlySpan str, DateTimeFormatInfo dtfi) m_checkDigitToken = ((dtfi.FormatFlags & DateTimeFormatFlags.UseDigitPrefixInTokens) != 0); } - internal CompareInfo CompareInfo => m_info; + internal readonly CompareInfo CompareInfo => m_info; // // Advance the Index. @@ -5292,7 +5292,7 @@ internal bool GetNext() return false; } - internal bool AtEnd() + internal readonly bool AtEnd() { return Index < Length ? false : true; } @@ -5430,13 +5430,13 @@ internal TokenType GetSeparatorToken(DateTimeFormatInfo dtfi, out int indexBefor } [MethodImpl(MethodImplOptions.AggressiveInlining)] - internal bool MatchSpecifiedWord(string target) => + internal readonly bool MatchSpecifiedWord(string target) => Index + target.Length <= Length && m_info.Compare(Value.Slice(Index, target.Length), target, CompareOptions.IgnoreCase) == 0; private static readonly char[] WhiteSpaceChecks = new char[] { ' ', '\u00A0' }; - internal bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int matchLength) + internal readonly bool MatchSpecifiedWords(string target, bool checkWordBoundary, ref int matchLength) { int valueRemaining = Value.Length - Index; matchLength = target.Length; @@ -5622,7 +5622,7 @@ internal bool GetNextDigit() => // // Get the current character. // - internal char GetChar() + internal readonly char GetChar() { Debug.Assert(Index >= 0 && Index < Length, "Index >= 0 && Index < len"); return Value[Index]; @@ -5631,7 +5631,7 @@ internal char GetChar() // // Convert the current character to a digit, and return it. // - internal int GetDigit() + internal readonly int GetDigit() { Debug.Assert(Index >= 0 && Index < Length, "Index >= 0 && Index < len"); Debug.Assert(DateTimeParse.IsDigit(Value[Index]), "IsDigit(Value[Index])"); @@ -5842,7 +5842,7 @@ internal ref struct DTSubString internal DTSubStringType type; internal int value; - internal char this[int relativeIndex] => s[index + relativeIndex]; + internal readonly char this[int relativeIndex] => s[index + relativeIndex]; } // @@ -5887,7 +5887,7 @@ internal void AddNumber(int value) num[numCount++] = value; } - internal int GetNumber(int index) + internal readonly int GetNumber(int index) { return num[index]; } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs index 1ed63ae31a7b5..edd2a8f1d588f 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanFormat.cs @@ -492,12 +492,12 @@ internal struct FormatLiterals private string[] _literals; - internal string Start => _literals[0]; - internal string DayHourSep => _literals[1]; - internal string HourMinuteSep => _literals[2]; - internal string MinuteSecondSep => _literals[3]; - internal string SecondFractionSep => _literals[4]; - internal string End => _literals[5]; + internal readonly string Start => _literals[0]; + internal readonly string DayHourSep => _literals[1]; + internal readonly string HourMinuteSep => _literals[2]; + internal readonly string MinuteSecondSep => _literals[3]; + internal readonly string SecondFractionSep => _literals[4]; + internal readonly string End => _literals[5]; /* factory method for static invariant FormatLiterals */ internal static FormatLiterals InitInvariant(bool isNegative) diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanParse.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanParse.cs index 2e7df616e238f..2fc02d4db0587 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanParse.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/TimeSpanParse.cs @@ -239,7 +239,7 @@ internal TimeSpanToken GetNextToken() return new TimeSpanToken(TTT.Sep, 0, 0, _value.Slice(pos, length)); } - internal bool EOL => _pos >= (_value.Length - 1); + internal readonly bool EOL => _pos >= (_value.Length - 1); internal void BackOne() { @@ -289,7 +289,7 @@ internal TimeSpanFormat.FormatLiterals NegativeLocalized } } - internal bool FullAppCompatMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullAppCompatMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 5 && _numCount == 4 && _literals0.EqualsOrdinal(pattern.Start) @@ -298,7 +298,7 @@ internal bool FullAppCompatMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals3.EqualsOrdinal(pattern.AppCompatLiteral) && _literals4.EqualsOrdinal(pattern.End); - internal bool PartialAppCompatMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool PartialAppCompatMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 4 && _numCount == 3 && _literals0.EqualsOrdinal(pattern.Start) @@ -307,7 +307,7 @@ internal bool PartialAppCompatMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals3.EqualsOrdinal(pattern.End); /// DHMSF (all values matched) - internal bool FullMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == MaxLiteralTokens && _numCount == MaxNumericTokens && _literals0.EqualsOrdinal(pattern.Start) @@ -318,14 +318,14 @@ internal bool FullMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals5.EqualsOrdinal(pattern.End); /// D (no hours, minutes, seconds, or fractions) - internal bool FullDMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullDMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 2 && _numCount == 1 && _literals0.EqualsOrdinal(pattern.Start) && _literals1.EqualsOrdinal(pattern.End); /// HM (no days, seconds, or fractions) - internal bool FullHMMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullHMMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 3 && _numCount == 2 && _literals0.EqualsOrdinal(pattern.Start) @@ -333,7 +333,7 @@ internal bool FullHMMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals2.EqualsOrdinal(pattern.End); /// DHM (no seconds or fraction) - internal bool FullDHMMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullDHMMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 4 && _numCount == 3 && _literals0.EqualsOrdinal(pattern.Start) @@ -342,7 +342,7 @@ internal bool FullDHMMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals3.EqualsOrdinal(pattern.End); /// HMS (no days or fraction) - internal bool FullHMSMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullHMSMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 4 && _numCount == 3 && _literals0.EqualsOrdinal(pattern.Start) @@ -351,7 +351,7 @@ internal bool FullHMSMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals3.EqualsOrdinal(pattern.End); /// DHMS (no fraction) - internal bool FullDHMSMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullDHMSMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 5 && _numCount == 4 && _literals0.EqualsOrdinal(pattern.Start) @@ -361,7 +361,7 @@ internal bool FullDHMSMatch(TimeSpanFormat.FormatLiterals pattern) => && _literals4.EqualsOrdinal(pattern.End); /// HMSF (no days) - internal bool FullHMSFMatch(TimeSpanFormat.FormatLiterals pattern) => + internal readonly bool FullHMSFMatch(TimeSpanFormat.FormatLiterals pattern) => _sepCount == 5 && _numCount == 4 && _literals0.EqualsOrdinal(pattern.Start) @@ -1476,7 +1476,7 @@ internal void NextChar() (char)0; } - internal char NextNonDigit() + internal readonly char NextNonDigit() { int i = _pos; while (i < _len) diff --git a/src/libraries/System.Private.CoreLib/src/System/HashCode.cs b/src/libraries/System.Private.CoreLib/src/System/HashCode.cs index 7a87e99416aa1..f89949793b6a5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/HashCode.cs +++ b/src/libraries/System.Private.CoreLib/src/System/HashCode.cs @@ -355,7 +355,7 @@ private void Add(int value) } } - public int ToHashCode() + public readonly int ToHashCode() { // Storing the value of _length locally shaves of quite a few bytes // in the resulting machine code. diff --git a/src/libraries/System.Private.CoreLib/src/System/Nullable.cs b/src/libraries/System.Private.CoreLib/src/System/Nullable.cs index 0fa9141483ee2..a1ba8ddb93b74 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Nullable.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Nullable.cs @@ -50,16 +50,16 @@ public readonly T Value public readonly T GetValueOrDefault(T defaultValue) => hasValue ? value : defaultValue; - public override bool Equals(object? other) + public override readonly bool Equals(object? other) { if (!hasValue) return other == null; if (other == null) return false; return value.Equals(other); } - public override int GetHashCode() => hasValue ? value.GetHashCode() : 0; + public override readonly int GetHashCode() => hasValue ? value.GetHashCode() : 0; - public override string? ToString() => hasValue ? value.ToString() : ""; + public override readonly string? ToString() => hasValue ? value.ToString() : ""; [NonVersionable] public static implicit operator Nullable(T value) => diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncVoidMethodBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncVoidMethodBuilder.cs index 0800965240718..85a30e4d4366a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncVoidMethodBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/AsyncVoidMethodBuilder.cs @@ -148,7 +148,7 @@ private void NotifySynchronizationContextOfCompletion() } /// Lazily instantiate the Task in a non-thread-safe manner. - private Task Task => _builder.Task; + private readonly Task Task => _builder.Task; /// /// Gets an object that may be used to uniquely identify this builder to the debugger. @@ -157,6 +157,6 @@ private void NotifySynchronizationContextOfCompletion() /// This property lazily instantiates the ID in a non-thread-safe manner. /// It must only be used by the debugger and AsyncCausalityTracer in a single-threaded manner. /// - internal object ObjectIdForDebugger => _builder.ObjectIdForDebugger; + internal readonly object ObjectIdForDebugger => _builder.ObjectIdForDebugger; } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.cs index b348c0b48161b..f29f71001bb7a 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/GCHandle.cs @@ -79,7 +79,7 @@ public void Free() // Target property - allows getting / updating of the handle's referent. public object? Target { - get + readonly get { IntPtr handle = _handle; ThrowIfInvalid(handle); @@ -142,7 +142,7 @@ public IntPtr AddrOfPinnedObject() } /// Determine whether this handle has been allocated or not. - public bool IsAllocated => _handle != IntPtr.Zero; + public readonly bool IsAllocated => _handle != IntPtr.Zero; /// /// Used to create a GCHandle from an int. This is intended to @@ -161,9 +161,9 @@ public static GCHandle FromIntPtr(IntPtr value) public static IntPtr ToIntPtr(GCHandle value) => value._handle; - public override int GetHashCode() => _handle.GetHashCode(); + public override readonly int GetHashCode() => _handle.GetHashCode(); - public override bool Equals([NotNullWhen(true)] object? o) => o is GCHandle && _handle == ((GCHandle)o)._handle; + public override readonly bool Equals([NotNullWhen(true)] object? o) => o is GCHandle && _handle == ((GCHandle)o)._handle; public static bool operator ==(GCHandle a, GCHandle b) => a._handle == b._handle; diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/SpanRuneEnumerator.cs b/src/libraries/System.Private.CoreLib/src/System/Text/SpanRuneEnumerator.cs index f27b22e4cee95..1ec33398d2e54 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/SpanRuneEnumerator.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/SpanRuneEnumerator.cs @@ -16,9 +16,9 @@ internal SpanRuneEnumerator(ReadOnlySpan buffer) _current = default; } - public Rune Current => _current; + public readonly Rune Current => _current; - public SpanRuneEnumerator GetEnumerator() => this; + public readonly SpanRuneEnumerator GetEnumerator() => this; public bool MoveNext() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs b/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs index 7111d94bca5b9..8ad062a924a2c 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/StringBuilder.cs @@ -582,7 +582,7 @@ public struct ChunkEnumerator /// Implement IEnumerable.GetEnumerator() to return 'this' as the IEnumerator /// [ComponentModel.EditorBrowsable(ComponentModel.EditorBrowsableState.Never)] // Only here to make foreach work - public ChunkEnumerator GetEnumerator() { return this; } + public readonly ChunkEnumerator GetEnumerator() { return this; } /// /// Implements the IEnumerator pattern. @@ -613,7 +613,7 @@ public bool MoveNext() /// /// Implements the IEnumerator pattern. /// - public ReadOnlyMemory Current + public readonly ReadOnlyMemory Current { get { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/StringRuneEnumerator.cs b/src/libraries/System.Private.CoreLib/src/System/Text/StringRuneEnumerator.cs index ebe0d228b4e01..493d19478c845 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/StringRuneEnumerator.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/StringRuneEnumerator.cs @@ -20,9 +20,9 @@ internal StringRuneEnumerator(string value) _nextIndex = 0; } - public Rune Current => _current; + public readonly Rune Current => _current; - public StringRuneEnumerator GetEnumerator() => this; + public readonly StringRuneEnumerator GetEnumerator() => this; public bool MoveNext() { @@ -56,9 +56,9 @@ void IDisposable.Dispose() // no-op } - IEnumerator IEnumerable.GetEnumerator() => this; + readonly IEnumerator IEnumerable.GetEnumerator() => this; - IEnumerator IEnumerable.GetEnumerator() => this; + readonly IEnumerator IEnumerable.GetEnumerator() => this; void IEnumerator.Reset() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs index 237e5e6771d47..b54e96499428d 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs @@ -202,13 +202,13 @@ internal Processor(ReadOnlySpan buffer, DecodeFirstRune decoder) CurrentCodeUnitOffset = 0; } - public int CurrentCodeUnitOffset { get; private set; } + public int CurrentCodeUnitOffset { readonly get; private set; } /// /// Will be if invalid data or EOF reached. /// Caller shouldn't need to special-case this since the normal rules will halt on this condition. /// - public GraphemeClusterBreakType CurrentType { get; private set; } + public GraphemeClusterBreakType CurrentType { readonly get; private set; } public void MoveNext() { diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs index 846e755904440..e14ff5e944284 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs @@ -39,7 +39,7 @@ public struct ManualResetValueTaskSourceCore /// Gets or sets whether to force continuations to run asynchronously. /// Continuations may run asynchronously if this is false, but they'll never run synchronously if this is true. - public bool RunContinuationsAsynchronously { get; set; } + public bool RunContinuationsAsynchronously { readonly get; set; } /// Resets to prepare for the next operation. public void Reset() @@ -72,11 +72,11 @@ public void SetException(Exception error) } /// Gets the operation version. - public short Version => _version; + public readonly short Version => _version; /// Gets the status of the operation. /// Opaque value that was provided to the 's constructor. - public ValueTaskSourceStatus GetStatus(short token) + public readonly ValueTaskSourceStatus GetStatus(short token) { ValidateToken(token); return @@ -89,7 +89,7 @@ public ValueTaskSourceStatus GetStatus(short token) /// Gets the result of the operation. /// Opaque value that was provided to the 's constructor. [StackTraceHidden] - public TResult GetResult(short token) + public readonly TResult GetResult(short token) { ValidateToken(token); if (!_completed) @@ -189,7 +189,7 @@ public void OnCompleted(Action continuation, object? state, short token /// Ensures that the specified token matches the current version. /// The token supplied by . - private void ValidateToken(short token) + private readonly void ValidateToken(short token) { if (token != _version) { @@ -235,7 +235,7 @@ private void SignalCompletion() } } - private void InvokeContinuationWithContext() + private readonly void InvokeContinuationWithContext() { // This is in a helper as the error handling causes the generated asm // for the surrounding code to become less efficent (stack spills etc) @@ -310,7 +310,7 @@ private void InvokeContinuationWithContext() /// This assumes that if is not null we're already /// running within that . /// - private void InvokeSchedulerContinuation() + private readonly void InvokeSchedulerContinuation() { Debug.Assert(_capturedContext != null); Debug.Assert(_continuation != null); diff --git a/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs b/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs index 5415a61d79076..b1499458f3c53 100644 --- a/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs +++ b/src/libraries/System.Private.CoreLib/src/System/ValueTuple.cs @@ -39,7 +39,7 @@ public struct ValueTuple /// /// The object to compare with this instance. /// if is a . - public override bool Equals([NotNullWhen(true)] object? obj) + public override readonly bool Equals([NotNullWhen(true)] object? obj) { return obj is ValueTuple; } @@ -47,17 +47,17 @@ public override bool Equals([NotNullWhen(true)] object? obj) /// Returns a value indicating whether this instance is equal to a specified value. /// An instance to compare to this instance. /// true if has the same value as this instance; otherwise, false. - public bool Equals(ValueTuple other) + public readonly bool Equals(ValueTuple other) { return true; } - bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) + readonly bool IStructuralEquatable.Equals(object? other, IEqualityComparer comparer) { return other is ValueTuple; } - int IComparable.CompareTo(object? other) + readonly int IComparable.CompareTo(object? other) { if (other is null) return 1; @@ -77,12 +77,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 0; } - int IStructuralComparable.CompareTo(object? other, IComparer comparer) + readonly int IStructuralComparable.CompareTo(object? other, IComparer comparer) { if (other is null) return 1; @@ -96,17 +96,17 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for this instance. /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return 0; } - int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) + readonly int IStructuralEquatable.GetHashCode(IEqualityComparer comparer) { return 0; } - int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) + readonly int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) { return 0; } @@ -118,12 +118,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// /// The string returned by this method takes the form (). /// - public override string ToString() + public override readonly string ToString() { return "()"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return ")"; } @@ -136,7 +136,7 @@ string IValueTupleInternal.ToStringEnd() /// /// Get the element at position . /// - object? ITuple.this[int index] => throw new IndexOutOfRangeException(); + readonly object?ITuple.this[int index] => throw new IndexOutOfRangeException(); /// Creates a new struct 0-tuple. /// A 0-tuple. @@ -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) { @@ -361,17 +361,17 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly 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!); } @@ -385,12 +385,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// where Item1 represents the value of . If the field is , /// it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ")"; } @@ -403,7 +403,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -558,24 +558,24 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(Item1?.GetHashCode() ?? 0, 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); } @@ -590,12 +590,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// and fields. If either field value is , /// it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ", " + Item2?.ToString() + ")"; } @@ -608,7 +608,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -755,26 +755,26 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(Item1?.GetHashCode() ?? 0, Item2?.GetHashCode() ?? 0, 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); } @@ -787,12 +787,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// The string returned by this method takes the form (Item1, Item2, Item3). /// If any field value is , it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ")"; } @@ -805,7 +805,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -968,7 +968,7 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(Item1?.GetHashCode() ?? 0, Item2?.GetHashCode() ?? 0, @@ -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); } @@ -1002,12 +1002,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// The string returned by this method takes the form (Item1, Item2, Item3, Item4). /// If any field value is , it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ")"; } @@ -1020,7 +1020,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -1198,7 +1198,7 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(Item1?.GetHashCode() ?? 0, Item2?.GetHashCode() ?? 0, @@ -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); } @@ -1234,12 +1234,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5). /// If any field value is , it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ")"; } @@ -1252,7 +1252,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -1446,7 +1446,7 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(Item1?.GetHashCode() ?? 0, Item2?.GetHashCode() ?? 0, @@ -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); } @@ -1484,12 +1484,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5, Item6). /// If any field value is , it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ")"; } @@ -1502,7 +1502,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -1712,7 +1712,7 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly int GetHashCode() { return HashCode.Combine(Item1?.GetHashCode() ?? 0, Item2?.GetHashCode() ?? 0, @@ -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); } @@ -1752,12 +1752,12 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5, Item6, Item7). /// If any field value is , it is represented as . /// - public override string ToString() + public override readonly string ToString() { return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { return Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ")"; } @@ -1770,7 +1770,7 @@ string IValueTupleInternal.ToStringEnd() /// /// 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) { @@ -2002,7 +2002,7 @@ int IStructuralComparable.CompareTo(object? other, IComparer comparer) /// Returns the hash code for the current instance. /// /// A 32-bit signed integer hash code. - public override int GetHashCode() + public override readonly 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 not IValueTupleInternal) @@ -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); } @@ -2164,7 +2164,7 @@ int IValueTupleInternal.GetHashCode(IEqualityComparer comparer) /// The string returned by this method takes the form (Item1, Item2, Item3, Item4, Item5, Item6, Item7, Rest). /// If any field value is , it is represented as . /// - public override string ToString() + public override readonly string ToString() { if (Rest is IValueTupleInternal) { @@ -2174,7 +2174,7 @@ public override string ToString() return "(" + Item1?.ToString() + ", " + Item2?.ToString() + ", " + Item3?.ToString() + ", " + Item4?.ToString() + ", " + Item5?.ToString() + ", " + Item6?.ToString() + ", " + Item7?.ToString() + ", " + Rest.ToString() + ")"; } - string IValueTupleInternal.ToStringEnd() + readonly string IValueTupleInternal.ToStringEnd() { if (Rest is IValueTupleInternal) { @@ -2192,7 +2192,7 @@ string IValueTupleInternal.ToStringEnd() /// /// Get the element at position . /// - object? ITuple.this[int index] + readonly object?ITuple.this[int index] { get { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs index 66e671cfaeb6c..dd13ab6127977 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/CollectionDataContract.cs @@ -86,26 +86,26 @@ internal KeyValue(K key, V value) [DataMember(IsRequired = true)] public K Key { - get { return _key; } + readonly get { return _key; } set { _key = value; } } [DataMember(IsRequired = true)] public V Value { - get { return _value; } + readonly get { return _value; } set { _value = value; } } object? IKeyValue.Key { - get { return _key; } + readonly get { return _key; } set { _key = (K)value!; } } object? IKeyValue.Value { - get { return _value; } + readonly get { return _value; } set { _value = (V)value!; } } } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DateTimeOffsetAdapter.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DateTimeOffsetAdapter.cs index 20cb05471fe63..c80294dfb0155 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DateTimeOffsetAdapter.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/DateTimeOffsetAdapter.cs @@ -24,14 +24,14 @@ public DateTimeOffsetAdapter(DateTime dateTime, short offsetMinutes) [DataMember(Name = "DateTime", IsRequired = true)] public DateTime UtcDateTime { - get { return _utcDateTime; } + readonly get { return _utcDateTime; } set { _utcDateTime = value; } } [DataMember(Name = "OffsetMinutes", IsRequired = true)] public short OffsetMinutes { - get { return _offsetMinutes; } + readonly get { return _offsetMinutes; } set { _offsetMinutes = value; } } @@ -64,7 +64,7 @@ public static DateTimeOffsetAdapter GetDateTimeOffsetAdapter(DateTimeOffset valu return new DateTimeOffsetAdapter(value.UtcDateTime, (short)value.Offset.TotalMinutes); } - public string ToString(IFormatProvider provider) + public readonly string ToString(IFormatProvider provider) { return "DateTime: " + this.UtcDateTime + ", Offset: " + this.OffsetMinutes; } diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ObjectReferenceStack.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ObjectReferenceStack.cs index 7945a647a124d..32b202070d2c9 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ObjectReferenceStack.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ObjectReferenceStack.cs @@ -84,7 +84,7 @@ internal void Pop(object obj) _count--; } - internal bool Contains(object obj) + internal readonly bool Contains(object obj) { int currentCount = _count; if (currentCount > MaximumArraySize) diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ScopedKnownTypes.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ScopedKnownTypes.cs index e9414b2a899d2..5c6a3e35d8918 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ScopedKnownTypes.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Runtime/Serialization/ScopedKnownTypes.cs @@ -25,7 +25,7 @@ internal void Pop() _count--; } - internal DataContract? GetDataContract(XmlQualifiedName qname) + internal readonly DataContract? GetDataContract(XmlQualifiedName qname) { for (int i = (_count - 1); i >= 0; i--) { diff --git a/src/libraries/System.Private.DataContractSerialization/src/System/Text/SurrogateChar.cs b/src/libraries/System.Private.DataContractSerialization/src/System/Text/SurrogateChar.cs index ef199a8f66f27..cb58573b69a20 100644 --- a/src/libraries/System.Private.DataContractSerialization/src/System/Text/SurrogateChar.cs +++ b/src/libraries/System.Private.DataContractSerialization/src/System/Text/SurrogateChar.cs @@ -43,10 +43,10 @@ public SurrogateChar(char lowChar, char highChar) _highChar = highChar; } - public char LowChar { get { return _lowChar; } } - public char HighChar { get { return _highChar; } } + public readonly char LowChar { get { return _lowChar; } } + public readonly char HighChar { get { return _highChar; } } - public int Char + public readonly int Char { get { diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.Enumerator.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.Enumerator.cs index d6e6005a83000..c86d9ab2f448c 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.Enumerator.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.Enumerator.cs @@ -30,7 +30,7 @@ public bool MoveNext() return false; } - public M Current + public readonly M Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] get diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.cs index a865e5d2b6b19..ecac5e414b356 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/BindingFlagSupport/QueryResult.cs @@ -21,7 +21,7 @@ public QueryResult(BindingFlags bindingAttr, QueriedMemberList queriedMembers _queriedMembers = queriedMembers; } - public QueryResultEnumerator GetEnumerator() => new QueryResultEnumerator(this); + public readonly QueryResultEnumerator GetEnumerator() => new QueryResultEnumerator(this); /// /// Returns the number of matching results. @@ -92,7 +92,7 @@ public void CopyTo(MemberInfo[] array, int startIndex) /// /// Returns a single member, null or throws AmbigousMatchException, for the Type.Get*(string name,...) family of apis. /// - public M? Disambiguate() + public readonly M? Disambiguate() { if (_queriedMembers == null) return null; // This is an uninitialized QueryResult, which is supported and represents a 0-length list of matches. @@ -127,7 +127,7 @@ public void CopyTo(MemberInfo[] array, int startIndex) return match; } - private int UnfilteredCount => ((_bindingAttr & BindingFlags.DeclaredOnly) != 0) ? _queriedMembers!.DeclaredOnlyCount : _queriedMembers!.TotalCount; + private readonly int UnfilteredCount => ((_bindingAttr & BindingFlags.DeclaredOnly) != 0) ? _queriedMembers!.DeclaredOnlyCount : _queriedMembers!.TotalCount; private readonly BindingFlags _bindingAttr; private int _lazyCount; // Intentionally not marking as volatile. QueryResult is for short-term use within a single method call - no aspiration to be thread-safe. diff --git a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/General/ListBuilder.cs b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/General/ListBuilder.cs index 8ef8009295178..a39f231418069 100644 --- a/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/General/ListBuilder.cs +++ b/src/libraries/System.Reflection.MetadataLoadContext/src/System/Reflection/Runtime/General/ListBuilder.cs @@ -21,7 +21,7 @@ public ListBuilder(int capacity) #endif // DEBUG } - public T this[int index] + public readonly T this[int index] { get { @@ -65,7 +65,7 @@ public void CopyTo(object[] array, int index) Array.Copy(_items!, 0, array, index, _count); } - public int Count + public readonly int Count { get { diff --git a/src/libraries/System.Runtime/ref/System.Runtime.cs b/src/libraries/System.Runtime/ref/System.Runtime.cs index 9317f89ec6960..4df1761ab9969 100644 --- a/src/libraries/System.Runtime/ref/System.Runtime.cs +++ b/src/libraries/System.Runtime/ref/System.Runtime.cs @@ -2285,7 +2285,7 @@ public void Add(T value, System.Collections.Generic.IEqualityComparer? com [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] [System.ObsoleteAttribute("HashCode is a mutable struct and should not be compared with other HashCodes. Use ToHashCode to retrieve the computed hash code.", true)] public override int GetHashCode() { throw null; } - public int ToHashCode() { throw null; } + public readonly int ToHashCode() { throw null; } } public partial class HttpStyleUriParser : System.UriParser { @@ -3037,13 +3037,13 @@ public partial struct Nullable where T : struct public Nullable(T value) { throw null; } public readonly bool HasValue { get { throw null; } } public readonly T Value { get { throw null; } } - public override bool Equals(object? other) { throw null; } - public override int GetHashCode() { throw null; } + public override readonly bool Equals(object? other) { throw null; } + public override readonly int GetHashCode() { throw null; } public readonly T GetValueOrDefault() { throw null; } public readonly T GetValueOrDefault(T defaultValue) { throw null; } public static explicit operator T (T? value) { throw null; } public static implicit operator T? (T value) { throw null; } - public override string? ToString() { throw null; } + public override readonly string? ToString() { throw null; } } public partial class NullReferenceException : System.SystemException { @@ -4880,9 +4880,9 @@ public enum UriPartial } public 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; } } + readonly 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 readonly int CompareTo(System.ValueTuple other) { throw null; } public static System.ValueTuple Create() { throw null; } public static System.ValueTuple Create(T1 item1) { throw null; } public static (T1, T2) Create(T1 item1, T2 item2) { throw null; } @@ -4892,47 +4892,47 @@ public partial struct ValueTuple : System.Collections.IStructuralComparable, Sys public static (T1, T2, T3, T4, T5, T6) Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) { throw null; } public static (T1, T2, T3, T4, T5, T6, T7) Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7) { throw null; } public static (T1, T2, T3, T4, T5, T6, T7, T8) Create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? obj) { throw null; } - public 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; } - public override string ToString() { 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 readonly override int GetHashCode() { 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 readonly string ToString() { throw null; } } public partial struct ValueTuple : System.Collections.IStructuralComparable, System.Collections.IStructuralEquatable, System.IComparable, System.IComparable>, System.IEquatable>, System.Runtime.CompilerServices.ITuple { public T1 Item1; public ValueTuple(T1 item1) { throw null; } - object? System.Runtime.CompilerServices.ITuple.this[int index] { get { throw null; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { @@ -4940,17 +4940,17 @@ 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { @@ -4959,17 +4959,17 @@ 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { @@ -4979,17 +4979,17 @@ 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { @@ -5000,17 +5000,17 @@ 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { @@ -5022,17 +5022,17 @@ 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly 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 { @@ -5045,17 +5045,17 @@ 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; } } + readonly 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; } - 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; } - public override string ToString() { 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 readonly int GetHashCode() { 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 readonly string ToString() { throw null; } } public abstract partial class ValueType { @@ -5314,10 +5314,10 @@ public partial struct DictionaryEntry private object _dummy; private int _dummyPrimitive; public DictionaryEntry(object key, object? value) { throw null; } - public object Key { get { throw null; } set { } } - public object? Value { get { throw null; } set { } } + public object Key { readonly get { throw null; } set { } } + public object? Value { readonly get { throw null; } set { } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public void Deconstruct(out object key, out object? value) { throw null; } + public readonly void Deconstruct(out object key, out object? value) { throw null; } } public partial class Hashtable : System.Collections.ICollection, System.Collections.IDictionary, System.Collections.IEnumerable, System.ICloneable, System.Runtime.Serialization.IDeserializationCallback, System.Runtime.Serialization.ISerializable { @@ -9811,15 +9811,15 @@ public FieldOffsetAttribute(int offset) { } public partial struct GCHandle { private int _dummyPrimitive; - public bool IsAllocated { get { throw null; } } - public object? Target { get { throw null; } set { } } + public readonly bool IsAllocated { get { throw null; } } + public object? Target { readonly get { throw null; } set { } } public System.IntPtr AddrOfPinnedObject() { throw null; } public static System.Runtime.InteropServices.GCHandle Alloc(object? value) { throw null; } public static System.Runtime.InteropServices.GCHandle Alloc(object? value, System.Runtime.InteropServices.GCHandleType type) { throw null; } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhenAttribute(true)] object? o) { throw null; } public void Free() { } public static System.Runtime.InteropServices.GCHandle FromIntPtr(System.IntPtr value) { throw null; } - public override int GetHashCode() { throw null; } + public override readonly int GetHashCode() { throw null; } public static bool operator ==(System.Runtime.InteropServices.GCHandle a, System.Runtime.InteropServices.GCHandle b) { throw null; } public static explicit operator System.Runtime.InteropServices.GCHandle (System.IntPtr value) { throw null; } public static explicit operator System.IntPtr (System.Runtime.InteropServices.GCHandle value) { throw null; } @@ -10931,9 +10931,9 @@ public partial struct ChunkEnumerator { private object _dummy; private int _dummyPrimitive; - public System.ReadOnlyMemory Current { get { throw null; } } + public readonly System.ReadOnlyMemory Current { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public System.Text.StringBuilder.ChunkEnumerator GetEnumerator() { throw null; } + public readonly System.Text.StringBuilder.ChunkEnumerator GetEnumerator() { throw null; } public bool MoveNext() { throw null; } } } @@ -10941,12 +10941,12 @@ public partial struct StringRuneEnumerator : System.Collections.Generic.IEnumera { private object _dummy; private int _dummyPrimitive; - public System.Text.Rune Current { get { throw null; } } + public readonly System.Text.Rune Current { get { throw null; } } object? System.Collections.IEnumerator.Current { get { throw null; } } - public System.Text.StringRuneEnumerator GetEnumerator() { throw null; } + public readonly System.Text.StringRuneEnumerator GetEnumerator() { throw null; } public bool MoveNext() { throw null; } - System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + readonly System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + readonly System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } void System.Collections.IEnumerator.Reset() { } void System.IDisposable.Dispose() { } } @@ -11561,9 +11561,9 @@ public partial struct ManualResetValueTaskSourceCore private object _dummy; private int _dummyPrimitive; public bool RunContinuationsAsynchronously { readonly get { throw null; } set { } } - public short Version { get { throw null; } } - public TResult GetResult(short token) { throw null; } - public System.Threading.Tasks.Sources.ValueTaskSourceStatus GetStatus(short token) { throw null; } + public readonly short Version { get { throw null; } } + public readonly TResult GetResult(short token) { throw null; } + public readonly System.Threading.Tasks.Sources.ValueTaskSourceStatus GetStatus(short token) { throw null; } public void OnCompleted(System.Action continuation, object? state, short token, System.Threading.Tasks.Sources.ValueTaskSourceOnCompletedFlags flags) { } public void Reset() { } public void SetException(System.Exception error) { } From a729883852094b105f834ac23d7f7b3efb1a000f Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 26 Apr 2021 23:06:41 +0300 Subject: [PATCH 3/3] remove redundant marking in auto getters --- .../ref/Microsoft.Bcl.AsyncInterfaces.cs | 2 +- .../Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs | 2 +- .../src/System/Text/Unicode/TextSegmentationUtility.cs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs index 4d1d8097fc18a..8df548882f1e0 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs @@ -84,7 +84,7 @@ public partial struct ManualResetValueTaskSourceCore private TResult _result; private object _dummy; private int _dummyPrimitive; - public bool RunContinuationsAsynchronously { readonly get { throw null; } set { } } + public bool RunContinuationsAsynchronously { get { throw null; } set { } } public readonly short Version { get { throw null; } } public readonly TResult GetResult(short token) { throw null; } public readonly System.Threading.Tasks.Sources.ValueTaskSourceStatus GetStatus(short token) { throw null; } diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs index 8d6553e53b6f3..b0ac853e09ee3 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs @@ -47,7 +47,7 @@ public struct ManualResetValueTaskSourceCore /// Gets or sets whether to force continuations to run asynchronously. /// Continuations may run asynchronously if this is false, but they'll never run synchronously if this is true. - public bool RunContinuationsAsynchronously { readonly get; set; } + public bool RunContinuationsAsynchronously { get; set; } /// Resets to prepare for the next operation. public void Reset() diff --git a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs index b54e96499428d..237e5e6771d47 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Text/Unicode/TextSegmentationUtility.cs @@ -202,13 +202,13 @@ internal Processor(ReadOnlySpan buffer, DecodeFirstRune decoder) CurrentCodeUnitOffset = 0; } - public int CurrentCodeUnitOffset { readonly get; private set; } + public int CurrentCodeUnitOffset { get; private set; } /// /// Will be if invalid data or EOF reached. /// Caller shouldn't need to special-case this since the normal rules will halt on this condition. /// - public GraphemeClusterBreakType CurrentType { readonly get; private set; } + public GraphemeClusterBreakType CurrentType { get; private set; } public void MoveNext() {