diff --git a/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs b/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs index 2da5179682d37..cf9c4361e34b5 100644 --- a/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs +++ b/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs @@ -78,10 +78,10 @@ public partial struct IPPacketInformation { private object _dummy; private int _dummyPrimitive; - public System.Net.IPAddress Address { get { throw null; } } - public int Interface { get { throw null; } } - public override bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object? comparand) { throw null; } - public override int GetHashCode() { throw null; } + public readonly System.Net.IPAddress Address { get { throw null; } } + public readonly int Interface { get { throw null; } } + public override readonly bool Equals([System.Diagnostics.CodeAnalysis.NotNullWhen(true)] object? comparand) { throw null; } + public override readonly int GetHashCode() { throw null; } public static bool operator ==(System.Net.Sockets.IPPacketInformation packetInformation1, System.Net.Sockets.IPPacketInformation packetInformation2) { throw null; } public static bool operator !=(System.Net.Sockets.IPPacketInformation packetInformation1, System.Net.Sockets.IPPacketInformation packetInformation2) { throw null; } } @@ -489,8 +489,8 @@ public partial struct SocketInformation { private object _dummy; private int _dummyPrimitive; - public System.Net.Sockets.SocketInformationOptions Options { readonly get { throw null; } set { } } - public byte[] ProtocolInformation { readonly get { throw null; } set { } } + public System.Net.Sockets.SocketInformationOptions Options { get { throw null; } set { } } + public byte[] ProtocolInformation { get { throw null; } set { } } } [System.FlagsAttribute] public enum SocketInformationOptions @@ -757,11 +757,11 @@ public partial struct UdpReceiveResult : System.IEquatable + public override readonly bool Equals([NotNullWhen(true)] object? comparand) => comparand is IPPacketInformation other && this == other; - public override int GetHashCode() + public override readonly int GetHashCode() { return unchecked(_networkInterface.GetHashCode() * (int)0xA5555529) + (_address == null ? 0 : _address.GetHashCode()); diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs index 7e4baeda1985d..983a85248851f 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncContext.Unix.cs @@ -742,9 +742,9 @@ private enum QueueState : int // never around any external call, e.g. OS call or user code invocation. private object _queueLock; - private LockToken Lock() => new LockToken(_queueLock); + private readonly LockToken Lock() => new LockToken(_queueLock); - public bool IsNextOperationSynchronous_Speculative => _isNextOperationSynchronous; + public readonly bool IsNextOperationSynchronous_Speculative => _isNextOperationSynchronous; public void Init() { @@ -1216,7 +1216,7 @@ public bool StopAndAbort(SocketAsyncContext context) } [Conditional("SOCKETASYNCCONTEXT_TRACE")] - public void Trace(SocketAsyncContext context, string message, [CallerMemberName] string? memberName = null) + public readonly void Trace(SocketAsyncContext context, string message, [CallerMemberName] string? memberName = null) { string queueType = typeof(TOperation) == typeof(ReadOperation) ? "recv" : diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketInformation.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketInformation.cs index e6cfa4ffcd72e..4a75ce7a31dc8 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketInformation.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketInformation.cs @@ -14,7 +14,7 @@ internal void SetOption(SocketInformationOptions option, bool value) else Options &= ~option; } - internal bool GetOption(SocketInformationOptions option) + internal readonly bool GetOption(SocketInformationOptions option) { return (Options & option) == option; } diff --git a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UdpReceiveResult.cs b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UdpReceiveResult.cs index 25af4a45bbaa1..fd025c67acf4b 100644 --- a/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UdpReceiveResult.cs +++ b/src/libraries/System.Net.Sockets/src/System/Net/Sockets/UdpReceiveResult.cs @@ -37,7 +37,7 @@ public UdpReceiveResult(byte[] buffer, IPEndPoint remoteEndPoint) /// /// Gets a buffer with the data received in the UDP packet /// - public byte[] Buffer + public readonly byte[] Buffer { get { @@ -48,7 +48,7 @@ public byte[] Buffer /// /// Gets the remote endpoint from which the UDP packet was received /// - public IPEndPoint RemoteEndPoint + public readonly IPEndPoint RemoteEndPoint { get { @@ -60,7 +60,7 @@ public IPEndPoint RemoteEndPoint /// Returns the hash code for this instance. /// /// The hash code - public override int GetHashCode() + public override readonly int GetHashCode() { return (_buffer != null) ? (_buffer.GetHashCode() ^ _remoteEndPoint.GetHashCode()) : 0; } @@ -70,7 +70,7 @@ public override int GetHashCode() /// /// The object to compare with this instance /// true if obj is an instance of and equals the value of the instance; otherwise, false - public override bool Equals([NotNullWhen(true)] object? obj) => + public override readonly bool Equals([NotNullWhen(true)] object? obj) => obj is UdpReceiveResult other && Equals(other); /// @@ -78,7 +78,7 @@ public override bool Equals([NotNullWhen(true)] object? obj) => /// /// The object to compare with this instance /// true if other is an instance of and equals the value of the instance; otherwise, false - public bool Equals(UdpReceiveResult other) + public readonly bool Equals(UdpReceiveResult other) { return object.Equals(_buffer, other._buffer) && object.Equals(_remoteEndPoint, other._remoteEndPoint); }