* Comment on awaits that don't need ConfigureAwait(false)
- Add comments to several awaits on tasks where ConfigureAwait is unnecessary for a variety of reasons
- Rather than commenting, change one await to GetAwaiter().GetResult() where we know the task is already completed (rather than just commenting to that effect)
* Add missing awaits to XmlTextReaderImplAsync
Commit migrated from https://github.com/dotnet/corefx/commit/b758c3b1f1293ada2e46f9e221be0b392838cc41
* Clean dead code in System.Net
* More cleaning
* Clean dead code for HttpListener
* Clean dead code for Mail
* Clean dead code in Http
* Clean dead code for NetworkInformation
* Clean more dead code
* Various fixes
* Build fix
* Restore field
* var -> string
Commit migrated from https://github.com/dotnet/corefx/commit/71cc1ae8ba02b7b71878cb69a50c667c8ed0f50f
* Change SocketsHttpHandler's 101 response stream to buffer response reads
The connection already has a buffer; use it.
* Reduce buffering in ManagedWebSocket.ReceiveAsync
Today we use a big-ish receive buffer, reading all data into the receive buffer and then copying from there into the caller-provided destination buffer. With this change, we assume that the underlying stream is providing the desired level of buffering, and thus only use a buffer small enough to handle message headers and control payloads (the latter for simplicity, as no caller-supplied buffer is available there).
* Change ClientWebSocket to avoid creating a large buffer
Commit migrated from https://github.com/dotnet/corefx/commit/06aa6f0ce4cdf78985f029f218007a7d55f8965f
* Use shared SocketsHttpHandler for some ClientWebSocket options
Currently we're creating a new SocketsHttpHandler for each ClientWebSocket. This change makes it so that if mostly default options are used (namely no credentials, no proxy, no cookies, and no client certificates), we'll use a shared handler instance.
* Make ClientWebSocketOptions.Proxy non-null by default
netfx's ClientWebSocketOptions.Proxy defaults to a system-default proxy. It can then be set to null to mean "no proxy" or to another proxy. This changes netcoreapp's Proxy to match as closely as possible.
It also then fixes up a few other settings on SocketsHttpHandler:
- UseDefaultCredentials wasn't being factored in. On netfx, UseDefaultCredentials takes precedence over Credentials, so this does the same.
- UseCookies should be true iff Cookies is non-null.
Finally, removed Outerloop from some tests that did not need to be, as they didn't actually involve making external requests, and deleted some dead test code.
Commit migrated from https://github.com/dotnet/corefx/commit/d4853e2cfd69cda68c0b17fd54b6c7d2d48b7f98
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
This fix addresses a behavior difference between the new managed WebSocket implementation and the old Windows only version.
When the underlying connection is closed, we need to also update the state of the WebSocket to show that it has been aborted. All of the code to do this was already written, it just needed to be called in one additional place.
Fixesdotnet/corefx#26219
Commit migrated from https://github.com/dotnet/corefx/commit/594a7f2a72dca255bb8e09613d3dcbb2499215de
* Clear initlocals in a bunch of assemblies
Sets
```XML
<ILLinkClearInitLocals>true</ILLinkClearInitLocals>
```
for the assemblies:
- System.IO.FileSystem
- System.IO.Pipes
- System.Memory
- System.Net.Http
- System.Net.Http.WinHttpHandler
- System.Net.NameResolution
- System.Net.NetworkInformation
- System.Net.Primitives
- System.Net.Requests
- System.Net.Security
- System.Net.Sockets
- System.Net.WebSockets
- System.Net.WebSockets.Client
- System.Net.WebSockets.WebSocketsProtocol
- System.Private.Uri
- System.Runtime
- System.Runtime.Extensions
Eventually we'd ideally set the flag for the whole repo; these are just the ones I audited thus far. In a few cases I had to make code changes to adapt, where the code was expecting stackallocs to be cleared. I also looked at a few other projects (System.Collections, System.Runtime.Numerics) where there were more significant dependencies on clearing and I decided to leave those for later.
* Disable ILLinkClearInitLocals running on Unix until it works there
Commit migrated from https://github.com/dotnet/corefx/commit/f0a032e4a1c8a848574a5db3e69e8a6fa0aae91e
- Renames ManagedHandler to SocketsHttpHandler
- Moves a bunch of files around accordingly
- Updates System.Net.WebSockets.Client to use SocketsHttpHandler directly
- Updates System.Net.Http's tests with a reflection-based rather than TLS-based method for instantiating an HttpClientHandler backed by a SocketsHttpHandler.
Commit migrated from https://github.com/dotnet/corefx/commit/852d40e723c849e8d0c486676d40332343e12ca5
* Add System.Drawing.Common to netcoreapp vertical
* Make System.Data.Odbc be able to build for netcoreapp vertical
* Add netcoreapp to System.Diagnostics.PerformanceCounter
* Add netcoreapp to System.Diagnostics.EventLog
* Run UpdateVSConfigurations
* Change Contains('netcoreapp') to StartsWith('netcoreapp')
* Include netcoreapp.depproj only when BuildAllConfigurations == true
* Change tests to netcoreapp from netcoreapp2.0 for vertical
Commit migrated from https://github.com/dotnet/corefx/commit/edacccb1cd6ecf7d36cd2379df8dd609ae0eb9a4
* Cleanup Windows 10 version detection
Windows 10 Version 1709 ("Fall Creators Update") has been released. This
PR cleans up the version detection to use the latest RTM build numbers
and removes obsolete InsiderPreview detection for those tests.
Also, removed ActiveIssue for tests that are now fixed due to Windows 10
fixes.
Fixesdotnet/corefx#22187
* Addressed feedback
Commit migrated from https://github.com/dotnet/corefx/commit/ac410223aa763a0f67880815057ee1bfe0f4cb6e
- At least until socket send/receives respect cancellation, we need to poll for cancellation after the handler's SendAsync completes.
- We're unnecessarily allocating another CTS if no external cancellation was provided.
- We're not disposing of the response object in the case of an error after SendAsync completes.
Commit migrated from https://github.com/dotnet/corefx/commit/baf2128a7cdf4a7638be1e86a6fc18651f3945d3
- Have ClientWebSocket change the scheme from http{s} -> ws{s} instead of having HttpClient accept ws{s} urls.
- Use a duplex response stream only when the status code is 101
- Disable a test that relies on connection opening being cancelable
Commit migrated from https://github.com/dotnet/corefx/commit/518ea1c2f8ad882c9829c8c35d27d92063ac67f7
ClientWebSocket's managed implementation currently has its own basic Socket-based code for establishing a websocket connection. This change switches it to use ManagedHandler instead, and in doing so benefits from improvements made to ManagedHandler thus far and in the future. For example, currently ManagedWebSocket doesn't support ClientWebSocketOptions.Proxy or ClientWebSocketOptions.Credentials, but since ManagedHandler does, now ManagedWebSocket does, too.
Commit migrated from https://github.com/dotnet/corefx/commit/db9f342cc43e0096b42d4d6d008c095da2bb8cfa
There's no guarantee that WebSocket.ReceiveAsync will return a complete message; in the extreme, a message can contain long.MaxValue bytes but the API only allows you to retrieve ~int.MaxValue at a time, but even way below that, it's common for ReceiveAsync to return the data it has available rather than gathering up all of the data from the message. However, several of the ConnectTest tests were depending on the full-message behavior. This commit fixes that.
Commit migrated from https://github.com/dotnet/corefx/commit/ffaf5375c00622b285997bc9626c042b9d64195c