Background and Motivation
For historical reasons, all of the Task-based APIs on Socket are defined as extension methods in SocketTaskExtensions.
We should move these methods to Socket itself, and mark the existing extension methods in SocketTaskExtensions as [EditorBrowsable(EditorBrowsableState.Never)].
Proposed API
namespaceSystem.Net.Sockets{publicpartialclassSocket{// Existing SocketTaskExtensions APIs, converted to instance methodspublicTask<Socket>AcceptAsync();publicTask<Socket>AcceptAsync(Socket?acceptSocket);publicTaskConnectAsync(EndPointremoteEP);publicValueTaskConnectAsync(EndPointremoteEP,CancellationTokencancellationToken);publicTaskConnectAsync(IPAddressaddress,intport);publicValueTaskConnectAsync(IPAddressaddress,intport,CancellationTokencancellationToken);publicTaskConnectAsync(IPAddress[]addresses,intport);publicValueTaskConnectAsync(IPAddress[]addresses,intport,CancellationTokencancellationToken);publicTaskConnectAsync(stringhost,intport);publicValueTaskConnectAsync(stringhost,intport,CancellationTokencancellationToken);publicTask<int>ReceiveAsync(ArraySegment<byte>buffer,SocketFlagssocketFlags);publicValueTask<int>ReceiveAsync(Memory<byte>buffer,SocketFlagssocketFlags,CancellationTokencancellationToken=default);publicTask<int>ReceiveAsync(IList<ArraySegment<byte>>buffers,SocketFlagssocketFlags);publicTask<SocketReceiveFromResult>ReceiveFromAsync(ArraySegment<byte>buffer,SocketFlagssocketFlags,EndPointremoteEndPoint);publicTask<SocketReceiveMessageFromResult>ReceiveMessageFromAsync(ArraySegment<byte>buffer,SocketFlagssocketFlags,EndPointremoteEndPoint);publicTask<int>SendAsync(ArraySegment<byte>buffer,SocketFlagssocketFlags);publicValueTask<int>SendAsync(ReadOnlyMemory<byte>buffer,SocketFlagssocketFlags,CancellationTokencancellationToken=default);publicTask<int>SendAsync(IList<ArraySegment<byte>>buffers,SocketFlagssocketFlags);publicTask<int>SendToAsync(ArraySegment<byte>buffer,SocketFlagssocketFlags,EndPointremoteEP);}}Note this change should apply to the following planned 6.0 APIs as well, which have already been approved as new extension methods on SocketTaskExtensions.
#1608
#42591
#33418
Background and Motivation
For historical reasons, all of the Task-based APIs on Socket are defined as extension methods in SocketTaskExtensions.
We should move these methods to Socket itself, and mark the existing extension methods in SocketTaskExtensions as [EditorBrowsable(EditorBrowsableState.Never)].
Proposed API
Note this change should apply to the following planned 6.0 APIs as well, which have already been approved as new extension methods on SocketTaskExtensions.
#1608
#42591
#33418