This commit does several things:
- Exposes the new `ValueTask` extensibility model being added in coreclr. The ValueTask-related files will separately be mirrored over to corefx to enable the netstandard build of System.Threading.Tasks.Extensions.
- Adapts all `Stream`-derived types to return `ValueTask` instead of `Task` from `WriteAsync`.
- Changes the new `WebSocket` `SendAsync` method to return `ValueTask` instead of `Task`, and updates the `ManagedWebSocket` implementation accordingly. Most `SendAsync`s on `ManagedWebSocket` should now return a `ValueTask` that's either completed synchronously (no allocation) or using a pooled object. It now uses the underlying transport's new `WriteAsync` overload that returns `ValueTask`.
- Switches more uses of `ReadAsync` and `WriteAsync` over to the new overloads, including in Process, DeflateStream, BrotliStream, File, HttpClient, SslStream, WebClient, BufferedStream, CryptoStream,
- Removed some unnecessary array clearing from various routines using ArrayPool (after the clearing was added we changed our minds and decided clearing was only necessary in very specific circumstances)
- Implements a custom `IValueTaskSource` in Socket, such that async receives and sends become allocation-free (ammortized). `NetworkStream` then inherits this functionality, such that its new `ReadAsync` and `WriteAsync` are also allocation-free (in the unbounded channel implementations; we can subsequently add it in for bounded).
- Implements a custom `IValueTaskSource` in System.Threading.Channels, such that reading and writing are ammortized allocation-free up to one concurrent reader and writer.
- A few random things I noticed as I was going through, e.g. missing ConfigureAwait, some incorrect synchronization in tests, etc.
- Adds a ton of new tests, mainly in System.Threading.Tasks.Extensions, System.Threading.Channels, and System.Net.Sockets.
Commit migrated from https://github.com/dotnet/corefx/commit/6d1671b2cfcf130b7bc6c059bb0508073426532a
Following our new guidelines for ref assembly implementations and what GenApi now creates, this updates all of our ref .cs files to use "throw null;" for member bodies that can't just be empty (i.e. members that need to return a value either via the return type or via an out parameter). I made the change programatically using a simple Roslyn-based tool.
Commit migrated from https://github.com/dotnet/corefx/commit/a9fdc79ff8feb5ad46e9fcbe18fdffcd0bd74679
Adds to System.Net.WebSockets:
- WebSocketException deriving from Win32Exception
- WebSocketException.ctor()
- WebSocket.DefaultKeepAliveInterval
- WebSocket.CreateClientBuffer
- WebSocket.CreateClientWebSocket
- WebSocket.CreateServerBuffer
- WebSocket.IsApplicationTargeting45
- WebSocket.IsStateTerminal
- WebSocket.ReisterPrefixes
- WebSocket.ThrowOnInvalidState
- WebSocketContext.RequestUri
- WebSocketContext.Headers
- WebSocketContext.Origin
- WebSocketContext.SecWebSocketProtocols
- WebSocketContext.SecWebSocketKey
- WebSocketContext.CookieCollection
- WebsocketContext.User
- WebSocketContext.IsAuthenticated
- WebSocketContext.IsLocal
- WebSocketContext.IsSecureConnection
- WebSocketContext.WebSocket
(Several of these members just throw PlatformNotSupportedException. Others have a different implementation than on desktop but something that's reasonable for corefx given the rest of the implementation's differences, e.g. limits on buffer sizes.)
Adds to System.Net.WebSockets.Client:
- ClientWebSocketOptions.UseDefaultCredentials
- ClientWebSocketOptions.SetBuffer(int, int)
- ClientWebSocketOptions.SetBuffer(int, int, ArraySegment<byte>)
As part of this, I also:
- Updated ClientWebSocketOptions.KeepAliveInterval to default to 30 seconds, as it does on desktop, rather than defaulting to 0.
- Updated the managed websockets implementation to take the ClientWebSocketOptions buffer information into account, in particular the receive buffer size and the buffer itself (as long as offset and count don't represent a subset, which would have been a more intrusive change to support).
Commit migrated from https://github.com/dotnet/corefx/commit/c97a2c7ac8ff5a4473348adf2ba6ca6a141de116
This change updates the assembly versions of all of the corefx assemblies
as needed after we shipped stable versions. Assemblies with API differences
get a minor version bump. Assemblies with only bugfixes get a build version
bump.
In order to facilitate this I had to update the reference assemblies, so I took
the opportunity to port them all to the open.
[tfs-changeset: 1514419]
Commit migrated from https://github.com/dotnet/corefx/commit/40723b795917f2e98b64d45c17effb2546dd0cae