Skip to content

Commit cb1beaa

Browse files
authored
Remove redundant pinvokes in S.N.Http/Mail on tvOS (#54812)
Addressed dotnet/macios#12011 (comment)
1 parent 2a5bae8 commit cb1beaa

File tree

4 files changed

+65
-18
lines changed

4 files changed

+65
-18
lines changed

src/libraries/Common/src/System/Net/NTAuthentication.Common.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
using System.Diagnostics.CodeAnalysis;
66
using System.Net.Security;
77
using System.Runtime.InteropServices;
8+
using System.Runtime.Versioning;
89
using System.Security.Authentication.ExtendedProtection;
910

1011
namespace System.Net
1112
{
13+
[UnsupportedOSPlatform("tvos")]
1214
internal sealed partial class NTAuthentication
1315
{
1416
private bool _isServer;

src/libraries/System.Net.Http/src/System.Net.Http.csproj

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
<Compile Include="System\Net\Http\Headers\KnownHeader.Http2And3.cs" />
144144
<Compile Include="System\Net\Http\SocketsHttpHandler\AuthenticationHelper.cs" />
145145
<Compile Include="System\Net\Http\SocketsHttpHandler\AuthenticationHelper.Digest.cs" />
146-
<Compile Include="System\Net\Http\SocketsHttpHandler\AuthenticationHelper.NtAuth.cs" />
146+
<Compile Condition="'$(TargetstvOS)' != 'true'" Include="System\Net\Http\SocketsHttpHandler\AuthenticationHelper.NtAuth.cs" />
147147
<Compile Include="System\Net\Http\SocketsHttpHandler\ChunkedEncodingReadStream.cs" />
148148
<Compile Include="System\Net\Http\SocketsHttpHandler\ChunkedEncodingWriteStream.cs" />
149149
<Compile Include="System\Net\Http\SocketsHttpHandler\ConnectHelper.cs" />
@@ -192,7 +192,7 @@
192192
<Compile Include="System\Net\Http\SocketsHttpHandler\SystemProxyInfo.cs" />
193193
<Compile Include="System\Net\Http\SocketsHttpHandler\SocksHelper.cs" />
194194
<Compile Include="System\Net\Http\SocketsHttpHandler\SocksException.cs" />
195-
<Compile Include="$(CommonPath)System\Net\NTAuthentication.Common.cs"
195+
<Compile Condition="'$(TargetstvOS)' != 'true'" Include="$(CommonPath)System\Net\NTAuthentication.Common.cs"
196196
Link="Common\System\Net\NTAuthentication.Common.cs" />
197197
<Compile Include="$(CommonPath)System\Net\ContextFlagsPal.cs"
198198
Link="Common\System\Net\ContextFlagsPal.cs" />
@@ -324,28 +324,37 @@
324324
Link="Common\System\Net\Security\Unix\SafeFreeCredentials.cs" />
325325
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteContext.cs"
326326
Link="Common\System\Net\Security\Unix\SafeDeleteContext.cs" />
327-
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.Unix.cs"
328-
Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" />
329-
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\GssSafeHandles.cs"
330-
Link="Common\Microsoft\Win32\SafeHandles\GssSafeHandles.cs" />
331-
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.GssApiException.cs"
332-
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.GssApiException.cs" />
333-
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeFreeNegoCredentials.cs"
334-
Link="Common\System\Net\Security\Unix\SafeFreeNegoCredentials.cs" />
335327
<Compile Include="$(CommonPath)System\Net\Security\Unix\SecChannelBindings.cs"
336328
Link="Common\System\Net\Security\Unix\SecChannelBindings.cs" />
337-
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.cs"
338-
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.cs" />
339329
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.GssFlags.cs"
340330
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.GssFlags.cs" />
341331
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.Status.cs"
342332
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.Status.cs" />
343333
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.IsNtlmInstalled.cs"
344334
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.IsNtlmInstalled.cs" />
335+
</ItemGroup>
336+
<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(TargetstvOS)' != 'true'">
337+
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.GssApiException.cs"
338+
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.GssApiException.cs" />
345339
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.GssBuffer.cs"
346340
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.GssBuffer.cs" />
341+
<Compile Include="$(CommonPath)Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.cs"
342+
Link="Common\Interop\Unix\System.Net.Security.Native\Interop.NetSecurityNative.cs" />
343+
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\GssSafeHandles.cs"
344+
Link="Common\Microsoft\Win32\SafeHandles\GssSafeHandles.cs" />
347345
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteNegoContext.cs"
348346
Link="Common\System\Net\Security\Unix\SafeDeleteNegoContext.cs" />
347+
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeFreeNegoCredentials.cs"
348+
Link="Common\System\Net\Security\Unix\SafeFreeNegoCredentials.cs" />
349+
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.Unix.cs"
350+
Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" />
351+
</ItemGroup>
352+
<ItemGroup Condition="'$(TargetstvOS)' == 'true'">
353+
<Compile Include="System\Net\Http\SocketsHttpHandler\AuthenticationHelper.NtAuth.tvOS.cs" />
354+
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\GssSafeHandles.PlatformNotSupported.cs"
355+
Link="Common\Microsoft\Win32\SafeHandles\GssSafeHandles.PlatformNotSupported.cs" />
356+
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.PlatformNotSupported.cs"
357+
Link="Common\System\Net\Security\NegotiateStreamPal.PlatformNotSupported.cs" />
349358
</ItemGroup>
350359
<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(TargetsOSX)' != 'true' and '$(TargetsiOS)' != 'true' and '$(TargetstvOS)' != 'true'">
351360
<Compile Include="System\Net\Http\SocketsHttpHandler\HttpNoProxy.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System.Diagnostics;
5+
using System.Threading;
6+
using System.Threading.Tasks;
7+
8+
namespace System.Net.Http
9+
{
10+
internal static partial class AuthenticationHelper
11+
{
12+
private static Task<HttpResponseMessage> InnerSendAsync(HttpRequestMessage request, Uri authUri, bool async, ICredentials credentials, bool isProxyAuth, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
13+
{
14+
return isProxyAuth ?
15+
SendWithProxyAuthAsync(request, authUri, async, credentials, true, connectionPool, cancellationToken).AsTask() :
16+
SendWithRequestAuthAsync(request, async, credentials, true, connectionPool, cancellationToken).AsTask();
17+
}
18+
19+
public static Task<HttpResponseMessage> SendWithNtProxyAuthAsync(HttpRequestMessage request, Uri proxyUri, bool async, ICredentials proxyCredentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
20+
{
21+
return InnerSendAsync(request, proxyUri, async, proxyCredentials, isProxyAuth: true, connection, connectionPool, cancellationToken);
22+
}
23+
24+
public static Task<HttpResponseMessage> SendWithNtConnectionAuthAsync(HttpRequestMessage request, bool async, ICredentials credentials, HttpConnection connection, HttpConnectionPool connectionPool, CancellationToken cancellationToken)
25+
{
26+
Debug.Assert(request.RequestUri != null);
27+
return InnerSendAsync(request, request.RequestUri, async, credentials, isProxyAuth: false, connection, connectionPool, cancellationToken);
28+
}
29+
}
30+
}

src/libraries/System.Net.Mail/src/System.Net.Mail.csproj

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,23 @@
153153
Link="Common\System\Net\Security\Unix\SafeDeleteNegoContext.cs" />
154154
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeFreeCredentials.cs"
155155
Link="Common\System\Net\Security\Unix\SafeFreeCredentials.cs" />
156-
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteContext.cs"
157-
Link="Common\System\Net\Security\Unix\SafeDeleteContext.cs" />
158-
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.Unix.cs"
159-
Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" />
160156
<Compile Include="$(CommonPath)Microsoft\Win32\SafeHandles\GssSafeHandles.cs"
161157
Link="Common\Microsoft\Win32\SafeHandles\GssSafeHandles.cs" />
162-
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeFreeNegoCredentials.cs"
163-
Link="Common\System\Net\Security\Unix\SafeFreeNegoCredentials.cs" />
164158
<Compile Include="$(CommonPath)System\Net\Security\Unix\SecChannelBindings.cs"
165159
Link="Common\System\Net\Security\Unix\SecChannelBindings.cs" />
166160
</ItemGroup>
161+
<ItemGroup Condition="'$(TargetsUnix)' == 'true' and '$(TargetstvOS)' != 'true'">
162+
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeFreeNegoCredentials.cs"
163+
Link="Common\System\Net\Security\Unix\SafeFreeNegoCredentials.cs" />
164+
<Compile Include="$(CommonPath)System\Net\Security\Unix\SafeDeleteContext.cs"
165+
Link="Common\System\Net\Security\Unix\SafeDeleteContext.cs" />
166+
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.Unix.cs"
167+
Link="Common\System\Net\Security\NegotiateStreamPal.Unix.cs" />
168+
</ItemGroup>
169+
<ItemGroup Condition="'$(TargetstvOS)' == 'true'">
170+
<Compile Include="$(CommonPath)System\Net\Security\NegotiateStreamPal.PlatformNotSupported.cs"
171+
Link="Common\System\Net\Security\NegotiateStreamPal.PlatformNotSupported.cs" />
172+
</ItemGroup>
167173
<!-- Windows specific files -->
168174
<ItemGroup Condition="'$(TargetsWindows)'=='true'">
169175
<Compile Include="$(CommonPath)System\Net\Security\SecurityBuffer.Windows.cs"

0 commit comments

Comments
 (0)