From bd72727b354a79f2fca7bf6f2169224d5a830506 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Mon, 28 Jun 2021 12:52:41 +0300 Subject: [PATCH 1/4] Remove redundant pinvokes in S.N.Http/Mail on tvOS --- .../src/System.Net.Http.csproj | 28 ++++++++++++------- .../src/System.Net.Mail.csproj | 18 ++++++++---- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index 1423025f7c1698..f4678822be05b3 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -322,28 +322,36 @@ Link="Common\System\Net\Security\Unix\SafeFreeCredentials.cs" /> - - - - - + + + + + + + + + + + diff --git a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj index b3350746d81827..a90d602beadd45 100644 --- a/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj +++ b/src/libraries/System.Net.Mail/src/System.Net.Mail.csproj @@ -153,17 +153,23 @@ Link="Common\System\Net\Security\Unix\SafeDeleteNegoContext.cs" /> - - - + + + + + + + + Date: Mon, 28 Jun 2021 18:10:38 +0300 Subject: [PATCH 2/4] Another portion of annotations to fix the tvos build --- .../src/System/Net/NTAuthentication.Common.cs | 2 ++ .../AuthenticationHelper.NtAuth.cs | 2 ++ .../HttpAuthenticatedConnectionHandler.cs | 2 ++ .../Net/Http/SocketsHttpHandler/HttpConnection.cs | 3 +++ .../SocketsHttpHandler/HttpConnectionHandler.cs | 2 ++ .../Http/SocketsHttpHandler/HttpConnectionPool.cs | 13 +++++++++++++ .../SocketsHttpHandler/HttpConnectionPoolManager.cs | 5 +++++ 7 files changed, 29 insertions(+) diff --git a/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs b/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs index b98f271183145e..148d1dc9a0700c 100644 --- a/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs +++ b/src/libraries/Common/src/System/Net/NTAuthentication.Common.cs @@ -5,10 +5,12 @@ using System.Diagnostics.CodeAnalysis; using System.Net.Security; using System.Runtime.InteropServices; +using System.Runtime.Versioning; using System.Security.Authentication.ExtendedProtection; namespace System.Net { + [UnsupportedOSPlatform("tvos")] internal sealed partial class NTAuthentication { private bool _isServer; diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs index 74abe97e80de91..ec0f6e4d98ee6d 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.cs @@ -5,12 +5,14 @@ using System.Diagnostics; using System.Net; using System.Net.Http.Headers; +using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using System.Security.Authentication.ExtendedProtection; namespace System.Net.Http { + [UnsupportedOSPlatform("tvos")] internal static partial class AuthenticationHelper { private static Task InnerSendAsync(HttpRequestMessage request, bool async, bool isProxyAuth, HttpConnectionPool pool, HttpConnection connection, CancellationToken cancellationToken) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs index 863a346bf426df..400ac75c779431 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; @@ -15,6 +16,7 @@ public HttpAuthenticatedConnectionHandler(HttpConnectionPoolManager poolManager) _poolManager = poolManager; } + [UnsupportedOSPlatform("tvos")] internal override ValueTask SendAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { return _poolManager.SendAsync(request, async, doRequestAuth: true, cancellationToken); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs index 00e3f3b6fe322f..e4ac0215c52641 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs @@ -11,6 +11,7 @@ using System.Net.Security; using System.Net.Sockets; using System.Runtime.CompilerServices; +using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -376,6 +377,7 @@ private Task WriteHexInt32Async(int value, bool async) return WriteAsciiStringAsync(value.ToString("X", CultureInfo.InvariantCulture), async); } + [UnsupportedOSPlatform("tvos")] public async Task SendAsyncCore(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { TaskCompletionSource? allowExpect100ToContinue = null; @@ -802,6 +804,7 @@ public async Task SendAsyncCore(HttpRequestMessage request, } } + [UnsupportedOSPlatform("tvos")] public sealed override Task SendAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) => SendAsyncCore(request, async, cancellationToken); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs index 8cfaa36497bcf4..adab5b43a2308a 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs @@ -1,6 +1,7 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; @@ -15,6 +16,7 @@ public HttpConnectionHandler(HttpConnectionPoolManager poolManager) _poolManager = poolManager; } + [UnsupportedOSPlatform("tvos")] internal override ValueTask SendAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { return _poolManager.SendAsync(request, async, doRequestAuth: false, cancellationToken); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs index 00a1a376799e2c..3597684462fc3b 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs @@ -471,6 +471,7 @@ private static HttpRequestException GetVersionException(HttpRequestMessage reque } // Returns null if HTTP2 cannot be used + [UnsupportedOSPlatform("tvos")] private async ValueTask GetHttp2ConnectionAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { Debug.Assert(_kind == HttpConnectionKind.Https || _kind == HttpConnectionKind.SslProxyTunnel || _kind == HttpConnectionKind.Http || _kind == HttpConnectionKind.SocksTunnel || _kind == HttpConnectionKind.SslSocksTunnel); @@ -812,6 +813,7 @@ private async ValueTask GetHttp3ConnectionAsync(HttpRequestMess } // Returns null if HTTP2 cannot be used. + [UnsupportedOSPlatform("tvos")] private async ValueTask TrySendUsingHttp2Async(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { // Send using HTTP/2 if we can. @@ -832,6 +834,7 @@ private async ValueTask GetHttp3ConnectionAsync(HttpRequestMess return null; } + [UnsupportedOSPlatform("tvos")] private async ValueTask SendUsingHttp11Async(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { HttpConnection? connection = await GetOrReserveHttp11ConnectionAsync(async, cancellationToken).ConfigureAwait(false); @@ -862,6 +865,7 @@ private async ValueTask SendUsingHttp11Async(HttpRequestMes } } + [UnsupportedOSPlatform("tvos")] private async ValueTask DetermineVersionAndSendAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { HttpResponseMessage? response; @@ -896,6 +900,7 @@ private async ValueTask DetermineVersionAndSendAsync(HttpRe return await SendUsingHttp11Async(request, async, doRequestAuth, cancellationToken).ConfigureAwait(false); } + [UnsupportedOSPlatform("tvos")] private async ValueTask SendAndProcessAltSvcAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { HttpResponseMessage response = await DetermineVersionAndSendAsync(request, async, doRequestAuth, cancellationToken).ConfigureAwait(false); @@ -909,6 +914,7 @@ private async ValueTask SendAndProcessAltSvcAsync(HttpReque return response; } + [UnsupportedOSPlatform("tvos")] public async ValueTask SendWithRetryAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { int retryCount = 0; @@ -1196,6 +1202,7 @@ public void OnNetworkChanged() } } + [UnsupportedOSPlatform("tvos")] public Task SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (doRequestAuth && Settings._credentials != null) @@ -1208,6 +1215,7 @@ public Task SendWithNtConnectionAuthAsync(HttpConnection co private bool DoProxyAuth => (_kind == HttpConnectionKind.Proxy || _kind == HttpConnectionKind.ProxyConnect); + [UnsupportedOSPlatform("tvos")] public Task SendWithNtProxyAuthAsync(HttpConnection connection, HttpRequestMessage request, bool async, CancellationToken cancellationToken) { if (DoProxyAuth && ProxyCredentials is not null) @@ -1218,6 +1226,7 @@ public Task SendWithNtProxyAuthAsync(HttpConnection connect return connection.SendAsync(request, async, cancellationToken); } + [UnsupportedOSPlatform("tvos")] public ValueTask SendWithProxyAuthAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (DoProxyAuth && ProxyCredentials is not null) @@ -1228,6 +1237,7 @@ public ValueTask SendWithProxyAuthAsync(HttpRequestMessage return SendWithRetryAsync(request, async, doRequestAuth, cancellationToken); } + [UnsupportedOSPlatform("tvos")] public ValueTask SendAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (doRequestAuth && Settings._credentials != null) @@ -1238,6 +1248,7 @@ public ValueTask SendAsync(HttpRequestMessage request, bool return SendWithProxyAuthAsync(request, async, doRequestAuth, cancellationToken); } + [UnsupportedOSPlatform("tvos")] private async ValueTask<(Socket?, Stream, TransportContext?)> ConnectAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { // If a non-infinite connect timeout has been set, create and use a new CancellationToken that will be canceled @@ -1358,6 +1369,7 @@ public ValueTask SendAsync(HttpRequestMessage request, bool } } + [UnsupportedOSPlatform("tvos")] internal async ValueTask CreateHttp11ConnectionAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { (Socket? socket, Stream? stream, TransportContext? transportContext) = @@ -1452,6 +1464,7 @@ private async ValueTask ConstructHttp2ConnectionAsync(Stream st return http2Connection; } + [UnsupportedOSPlatform("tvos")] private async ValueTask EstablishProxyTunnelAsync(bool async, HttpRequestHeaders? headers, CancellationToken cancellationToken) { Debug.Assert(_originAuthority != null); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs index e257cb4c3e692f..6690a0b26c1d3a 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs @@ -6,6 +6,7 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.ExceptionServices; +using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using System.Net.NetworkInformation; @@ -326,6 +327,7 @@ private HttpConnectionKey GetConnectionKey(HttpRequestMessage request, Uri? prox } } + [UnsupportedOSPlatform("tvos")] public ValueTask SendAsyncCore(HttpRequestMessage request, Uri? proxyUri, bool async, bool doRequestAuth, bool isProxyConnect, CancellationToken cancellationToken) { HttpConnectionKey key = GetConnectionKey(request, proxyUri, isProxyConnect); @@ -365,11 +367,13 @@ public ValueTask SendAsyncCore(HttpRequestMessage request, return pool.SendAsync(request, async, doRequestAuth, cancellationToken); } + [UnsupportedOSPlatform("tvos")] public ValueTask SendProxyConnectAsync(HttpRequestMessage request, Uri proxyUri, bool async, CancellationToken cancellationToken) { return SendAsyncCore(request, proxyUri, async, doRequestAuth: false, isProxyConnect: true, cancellationToken); } + [UnsupportedOSPlatform("tvos")] public ValueTask SendAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (_proxy == null) @@ -423,6 +427,7 @@ public ValueTask SendAsync(HttpRequestMessage request, bool /// The set of proxies to use. /// The first proxy try. /// The cancellation token to use for the operation. + [UnsupportedOSPlatform("tvos")] private async ValueTask SendAsyncMultiProxy(HttpRequestMessage request, bool async, bool doRequestAuth, MultiProxy multiProxy, Uri? firstProxy, CancellationToken cancellationToken) { HttpRequestException rethrowException; From bde0bf9c36504988fb2ce86b4670122329c4fd20 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Thu, 8 Jul 2021 12:56:09 +0300 Subject: [PATCH 3/4] Extract AuthenticationHelper class to a separate file for tvOS; --- .../src/System.Net.Http.csproj | 3 +- .../AuthenticationHelper.NtAuth.cs | 2 -- .../AuthenticationHelper.NtAuth.tvOS.cs | 30 +++++++++++++++++++ .../HttpAuthenticatedConnectionHandler.cs | 2 -- .../Http/SocketsHttpHandler/HttpConnection.cs | 3 -- .../HttpConnectionHandler.cs | 2 -- .../SocketsHttpHandler/HttpConnectionPool.cs | 13 -------- .../HttpConnectionPoolManager.cs | 5 ---- 8 files changed, 32 insertions(+), 28 deletions(-) create mode 100644 src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.tvOS.cs diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index d9e3dbd9ae1c6d..c65283a22a01bb 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -142,7 +142,7 @@ - + @@ -348,6 +348,7 @@ Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" /> + InnerSendAsync(HttpRequestMessage request, bool async, bool isProxyAuth, HttpConnectionPool pool, HttpConnection connection, CancellationToken cancellationToken) diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.tvOS.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.tvOS.cs new file mode 100644 index 00000000000000..86b2eacbb1845f --- /dev/null +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/AuthenticationHelper.NtAuth.tvOS.cs @@ -0,0 +1,30 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using System.Threading; +using System.Threading.Tasks; + +namespace System.Net.Http +{ + internal static partial class AuthenticationHelper + { + private static Task InnerSendAsync(HttpRequestMessage request, Uri authUri, bool async, ICredentials credentials, bool isProxyAuth, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken) + { + return isProxyAuth ? + SendWithProxyAuthAsync(request, authUri, async, credentials, true, connectionPool, cancellationToken).AsTask() : + SendWithRequestAuthAsync(request, async, credentials, true, connectionPool, cancellationToken).AsTask(); + } + + public static Task SendWithNtProxyAuthAsync(HttpRequestMessage request, Uri proxyUri, bool async, ICredentials proxyCredentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken) + { + return InnerSendAsync(request, proxyUri, async, proxyCredentials, isProxyAuth: true, connection, connectionPool, cancellationToken); + } + + public static Task SendWithNtConnectionAuthAsync(HttpRequestMessage request, bool async, ICredentials credentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken) + { + Debug.Assert(request.RequestUri != null); + return InnerSendAsync(request, request.RequestUri, async, credentials, isProxyAuth: false, connection, connectionPool, cancellationToken); + } + } +} \ No newline at end of file diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs index 400ac75c779431..863a346bf426df 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpAuthenticatedConnectionHandler.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; @@ -16,7 +15,6 @@ public HttpAuthenticatedConnectionHandler(HttpConnectionPoolManager poolManager) _poolManager = poolManager; } - [UnsupportedOSPlatform("tvos")] internal override ValueTask SendAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { return _poolManager.SendAsync(request, async, doRequestAuth: true, cancellationToken); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs index e4ac0215c52641..00e3f3b6fe322f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnection.cs @@ -11,7 +11,6 @@ using System.Net.Security; using System.Net.Sockets; using System.Runtime.CompilerServices; -using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -377,7 +376,6 @@ private Task WriteHexInt32Async(int value, bool async) return WriteAsciiStringAsync(value.ToString("X", CultureInfo.InvariantCulture), async); } - [UnsupportedOSPlatform("tvos")] public async Task SendAsyncCore(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { TaskCompletionSource? allowExpect100ToContinue = null; @@ -804,7 +802,6 @@ public async Task SendAsyncCore(HttpRequestMessage request, } } - [UnsupportedOSPlatform("tvos")] public sealed override Task SendAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) => SendAsyncCore(request, async, cancellationToken); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs index adab5b43a2308a..8cfaa36497bcf4 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionHandler.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; @@ -16,7 +15,6 @@ public HttpConnectionHandler(HttpConnectionPoolManager poolManager) _poolManager = poolManager; } - [UnsupportedOSPlatform("tvos")] internal override ValueTask SendAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { return _poolManager.SendAsync(request, async, doRequestAuth: false, cancellationToken); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs index 3597684462fc3b..00a1a376799e2c 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs @@ -471,7 +471,6 @@ private static HttpRequestException GetVersionException(HttpRequestMessage reque } // Returns null if HTTP2 cannot be used - [UnsupportedOSPlatform("tvos")] private async ValueTask GetHttp2ConnectionAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { Debug.Assert(_kind == HttpConnectionKind.Https || _kind == HttpConnectionKind.SslProxyTunnel || _kind == HttpConnectionKind.Http || _kind == HttpConnectionKind.SocksTunnel || _kind == HttpConnectionKind.SslSocksTunnel); @@ -813,7 +812,6 @@ private async ValueTask GetHttp3ConnectionAsync(HttpRequestMess } // Returns null if HTTP2 cannot be used. - [UnsupportedOSPlatform("tvos")] private async ValueTask TrySendUsingHttp2Async(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { // Send using HTTP/2 if we can. @@ -834,7 +832,6 @@ private async ValueTask GetHttp3ConnectionAsync(HttpRequestMess return null; } - [UnsupportedOSPlatform("tvos")] private async ValueTask SendUsingHttp11Async(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { HttpConnection? connection = await GetOrReserveHttp11ConnectionAsync(async, cancellationToken).ConfigureAwait(false); @@ -865,7 +862,6 @@ private async ValueTask SendUsingHttp11Async(HttpRequestMes } } - [UnsupportedOSPlatform("tvos")] private async ValueTask DetermineVersionAndSendAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { HttpResponseMessage? response; @@ -900,7 +896,6 @@ private async ValueTask DetermineVersionAndSendAsync(HttpRe return await SendUsingHttp11Async(request, async, doRequestAuth, cancellationToken).ConfigureAwait(false); } - [UnsupportedOSPlatform("tvos")] private async ValueTask SendAndProcessAltSvcAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { HttpResponseMessage response = await DetermineVersionAndSendAsync(request, async, doRequestAuth, cancellationToken).ConfigureAwait(false); @@ -914,7 +909,6 @@ private async ValueTask SendAndProcessAltSvcAsync(HttpReque return response; } - [UnsupportedOSPlatform("tvos")] public async ValueTask SendWithRetryAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { int retryCount = 0; @@ -1202,7 +1196,6 @@ public void OnNetworkChanged() } } - [UnsupportedOSPlatform("tvos")] public Task SendWithNtConnectionAuthAsync(HttpConnection connection, HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (doRequestAuth && Settings._credentials != null) @@ -1215,7 +1208,6 @@ public Task SendWithNtConnectionAuthAsync(HttpConnection co private bool DoProxyAuth => (_kind == HttpConnectionKind.Proxy || _kind == HttpConnectionKind.ProxyConnect); - [UnsupportedOSPlatform("tvos")] public Task SendWithNtProxyAuthAsync(HttpConnection connection, HttpRequestMessage request, bool async, CancellationToken cancellationToken) { if (DoProxyAuth && ProxyCredentials is not null) @@ -1226,7 +1218,6 @@ public Task SendWithNtProxyAuthAsync(HttpConnection connect return connection.SendAsync(request, async, cancellationToken); } - [UnsupportedOSPlatform("tvos")] public ValueTask SendWithProxyAuthAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (DoProxyAuth && ProxyCredentials is not null) @@ -1237,7 +1228,6 @@ public ValueTask SendWithProxyAuthAsync(HttpRequestMessage return SendWithRetryAsync(request, async, doRequestAuth, cancellationToken); } - [UnsupportedOSPlatform("tvos")] public ValueTask SendAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (doRequestAuth && Settings._credentials != null) @@ -1248,7 +1238,6 @@ public ValueTask SendAsync(HttpRequestMessage request, bool return SendWithProxyAuthAsync(request, async, doRequestAuth, cancellationToken); } - [UnsupportedOSPlatform("tvos")] private async ValueTask<(Socket?, Stream, TransportContext?)> ConnectAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { // If a non-infinite connect timeout has been set, create and use a new CancellationToken that will be canceled @@ -1369,7 +1358,6 @@ public ValueTask SendAsync(HttpRequestMessage request, bool } } - [UnsupportedOSPlatform("tvos")] internal async ValueTask CreateHttp11ConnectionAsync(HttpRequestMessage request, bool async, CancellationToken cancellationToken) { (Socket? socket, Stream? stream, TransportContext? transportContext) = @@ -1464,7 +1452,6 @@ private async ValueTask ConstructHttp2ConnectionAsync(Stream st return http2Connection; } - [UnsupportedOSPlatform("tvos")] private async ValueTask EstablishProxyTunnelAsync(bool async, HttpRequestHeaders? headers, CancellationToken cancellationToken) { Debug.Assert(_originAuthority != null); diff --git a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs index 6690a0b26c1d3a..e257cb4c3e692f 100644 --- a/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs +++ b/src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.cs @@ -6,7 +6,6 @@ using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Runtime.ExceptionServices; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Tasks; using System.Net.NetworkInformation; @@ -327,7 +326,6 @@ private HttpConnectionKey GetConnectionKey(HttpRequestMessage request, Uri? prox } } - [UnsupportedOSPlatform("tvos")] public ValueTask SendAsyncCore(HttpRequestMessage request, Uri? proxyUri, bool async, bool doRequestAuth, bool isProxyConnect, CancellationToken cancellationToken) { HttpConnectionKey key = GetConnectionKey(request, proxyUri, isProxyConnect); @@ -367,13 +365,11 @@ public ValueTask SendAsyncCore(HttpRequestMessage request, return pool.SendAsync(request, async, doRequestAuth, cancellationToken); } - [UnsupportedOSPlatform("tvos")] public ValueTask SendProxyConnectAsync(HttpRequestMessage request, Uri proxyUri, bool async, CancellationToken cancellationToken) { return SendAsyncCore(request, proxyUri, async, doRequestAuth: false, isProxyConnect: true, cancellationToken); } - [UnsupportedOSPlatform("tvos")] public ValueTask SendAsync(HttpRequestMessage request, bool async, bool doRequestAuth, CancellationToken cancellationToken) { if (_proxy == null) @@ -427,7 +423,6 @@ public ValueTask SendAsync(HttpRequestMessage request, bool /// The set of proxies to use. /// The first proxy try. /// The cancellation token to use for the operation. - [UnsupportedOSPlatform("tvos")] private async ValueTask SendAsyncMultiProxy(HttpRequestMessage request, bool async, bool doRequestAuth, MultiProxy multiProxy, Uri? firstProxy, CancellationToken cancellationToken) { HttpRequestException rethrowException; From 5012e6565129e798db3fcd1be5690d52f3bf9c48 Mon Sep 17 00:00:00 2001 From: Maxim Lipnin Date: Fri, 9 Jul 2021 10:47:35 +0300 Subject: [PATCH 4/4] Exclude NTAuthentication.Common.cs on tvOS --- src/libraries/System.Net.Http/src/System.Net.Http.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Net.Http/src/System.Net.Http.csproj b/src/libraries/System.Net.Http/src/System.Net.Http.csproj index ffac0342822ad1..bea0e12f9fe004 100644 --- a/src/libraries/System.Net.Http/src/System.Net.Http.csproj +++ b/src/libraries/System.Net.Http/src/System.Net.Http.csproj @@ -192,7 +192,7 @@ -