Skip to content

Commit aaecee0

Browse files
geoffkizerGeoffrey Kizerscalablecory
authored
Remove System.Net.Connections and related features (#41648)
* remove System.Net.Connections and related features * cleanup csproj changes * Update src/libraries/pkg/baseline/packageIndex.json Co-authored-by: Cory Nelson <[email protected]> * Update src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.Tasks.cs Co-authored-by: Cory Nelson <[email protected]> Co-authored-by: Geoffrey Kizer <[email protected]> Co-authored-by: Cory Nelson <[email protected]>
1 parent 10b262b commit aaecee0

32 files changed

+249
-420
lines changed

src/libraries/NetCoreAppLibrary.props

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
System.IO.FileSystem.Watcher;
4949
System.IO.IsolatedStorage;
5050
System.IO.MemoryMappedFiles;
51-
System.IO.Pipelines;
5251
System.IO.Pipes;
5352
System.IO.Pipes.AccessControl;
5453
System.IO.UnmanagedMemoryStream;
@@ -57,7 +56,6 @@
5756
System.Linq.Parallel;
5857
System.Linq.Queryable;
5958
System.Memory;
60-
System.Net.Connections;
6159
System.Net.Http;
6260
System.Net.Http.Json;
6361
System.Net.HttpListener;

src/libraries/System.Net.Connections/ref/System.Net.Connections.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,24 @@ public SocketsConnectionFactory(System.Net.Sockets.SocketType socketType, System
7979
protected virtual System.Net.Sockets.Socket CreateSocket(System.Net.Sockets.AddressFamily addressFamily, System.Net.Sockets.SocketType socketType, System.Net.Sockets.ProtocolType protocolType, System.Net.EndPoint? endPoint, System.Net.Connections.IConnectionProperties? options) { throw null; }
8080
}
8181
}
82+
namespace System.Net
83+
{
84+
public enum NetworkError : int
85+
{
86+
Other = 0,
87+
EndPointInUse,
88+
HostNotFound,
89+
TimedOut,
90+
ConnectionRefused,
91+
OperationAborted,
92+
ConnectionAborted,
93+
ConnectionReset,
94+
}
95+
public class NetworkException : System.IO.IOException
96+
{
97+
public NetworkException(NetworkError error, Exception? innerException = null) { }
98+
public NetworkException(string message, NetworkError error, Exception? innerException = null) { }
99+
protected NetworkException(System.Runtime.Serialization.SerializationInfo serializationInfo, System.Runtime.Serialization.StreamingContext streamingContext) { }
100+
public NetworkError NetworkError { get { throw null; } }
101+
}
102+
}

src/libraries/System.Net.Connections/src/System.Net.Connections.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<ItemGroup>
77
<Compile Include="$(CommonPath)System\Net\NetworkErrorHelper.cs" Link="Common\System\Net\NetworkErrorHelper.cs" />
88
<Compile Include="$(CommonPath)System\Threading\Tasks\TaskToApm.cs" Link="Common\System\Threading\Tasks\TaskToApm.cs" />
9+
<Compile Include="System\Net\NetworkError.cs" />
10+
<Compile Include="System\Net\NetworkException.cs" />
911
<Compile Include="System\Net\Connections\ConnectionBase.cs" />
1012
<Compile Include="System\Net\Connections\ConnectionCloseMethod.cs" />
1113
<Compile Include="System\Net\Connections\ConnectionExtensions.cs" />
@@ -20,13 +22,13 @@
2022
<Compile Include="System\Net\Connections\Sockets\SocketsConnectionFactory.cs" />
2123
</ItemGroup>
2224
<ItemGroup>
25+
<ProjectReference Include="..\..\System.IO.Pipelines\ref\System.IO.Pipelines.csproj" />
2326
<Reference Include="System.Runtime" />
2427
<Reference Include="System.Memory" />
2528
<Reference Include="System.Net.Primitives" />
2629
<Reference Include="System.Net.Sockets" />
2730
<Reference Include="System.Threading" />
2831
<Reference Include="System.Threading.Tasks" />
29-
<Reference Include="System.IO.Pipelines" />
3032
<Reference Include="Microsoft.Win32.Primitives" />
3133
</ItemGroup>
3234
</Project>

src/libraries/System.Net.Primitives/src/System/Net/NetworkError.cs renamed to src/libraries/System.Net.Connections/src/System/Net/NetworkError.cs

File renamed without changes.

src/libraries/System.Net.Primitives/src/System/Net/NetworkException.cs renamed to src/libraries/System.Net.Connections/src/System/Net/NetworkException.cs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,7 @@ public override void GetObjectData(SerializationInfo serializationInfo, Streamin
3838
/// <summary>Returns the specific kind of error.</summary>
3939
public NetworkError NetworkError { get; }
4040

41-
private static string GetExceptionMessage(NetworkError error) => error switch
42-
{
43-
NetworkError.EndPointInUse => SR.networkerror_addressinuse,
44-
NetworkError.TimedOut => SR.networkerror_timedout,
45-
NetworkError.HostNotFound => SR.networkerror_hostnotfound,
46-
NetworkError.ConnectionRefused => SR.networkerror_connectionrefused,
47-
NetworkError.ConnectionAborted => SR.networkerror_connectionaborted,
48-
NetworkError.ConnectionReset => SR.networkerror_connectionreset,
49-
NetworkError.OperationAborted => SR.networkerror_operationaborted,
50-
_ => SR.networkerror_other
51-
};
41+
// TODO: Better exception messages
42+
private static string GetExceptionMessage(NetworkError error) => $"A network error occurred: {error}";
5243
}
5344
}

src/libraries/System.Net.Connections/tests/System.Net.Connections.Tests/Sockets/SocketsConnectionFactoryTests.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -225,36 +225,6 @@ public async Task Connection_Pipe_ReadWrite_Success(EndPoint endPoint, SocketTyp
225225
Assert.True(rr.Buffer.FirstSpan.SequenceEqual(sendData));
226226
}
227227

228-
[Fact]
229-
public async Task Connection_Stream_FailingOperation_ThowsNetworkException()
230-
{
231-
using var server = SocketTestServer.SocketTestServerFactory(SocketImplementationType.Async, IPAddress.Loopback);
232-
using SocketsConnectionFactory factory = new SocketsConnectionFactory(SocketType.Stream, ProtocolType.Tcp);
233-
using Connection connection = await factory.ConnectAsync(server.EndPoint);
234-
235-
connection.ConnectionProperties.TryGet(out Socket socket);
236-
Stream stream = connection.Stream;
237-
socket.Dispose();
238-
239-
Assert.Throws<NetworkException>(() => stream.Read(new byte[1], 0, 1));
240-
Assert.Throws<NetworkException>(() => stream.Write(new byte[1], 0, 1));
241-
}
242-
243-
[Fact]
244-
public async Task Connection_Pipe_FailingOperation_ThowsNetworkException()
245-
{
246-
using var server = SocketTestServer.SocketTestServerFactory(SocketImplementationType.Async, IPAddress.Loopback);
247-
using SocketsConnectionFactory factory = new SocketsConnectionFactory(SocketType.Stream, ProtocolType.Tcp);
248-
using Connection connection = await factory.ConnectAsync(server.EndPoint);
249-
250-
connection.ConnectionProperties.TryGet(out Socket socket);
251-
IDuplexPipe pipe = connection.Pipe;
252-
socket.Dispose();
253-
254-
await Assert.ThrowsAsync<NetworkException>(() => pipe.Input.ReadAsync().AsTask());
255-
await Assert.ThrowsAsync<NetworkException>(() => pipe.Output.WriteAsync(new byte[1]).AsTask());
256-
}
257-
258228
[Theory]
259229
[InlineData(false, false)]
260230
[InlineData(false, true)]

src/libraries/System.Net.Connections/tests/System.Net.Connections.Tests/System.Net.Connections.Tests.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@
3030
<Compile Include="$(CommonTestPath)System\Net\Sockets\SocketImplementationType.cs" Link="SocketCommon\SocketImplementationType.cs" />
3131
<Compile Include="$(CommonTestPath)System\Threading\Tasks\TaskTimeoutExtensions.cs" Link="Common\System\Threading\Tasks\TaskTimeoutExtensions.cs" />
3232
</ItemGroup>
33+
<ItemGroup>
34+
<ProjectReference Include="..\..\..\System.IO.Pipelines\src\System.IO.Pipelines.csproj" />
35+
<ProjectReference Include="..\..\..\System.Net.Connections\src\System.Net.Connections.csproj" />
36+
</ItemGroup>
3337

3438
</Project>

src/libraries/System.Net.Http/ref/System.Net.Http.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,6 @@ public SocketsHttpHandler() { }
331331
public static bool IsSupported { get { throw null; } }
332332
public bool AllowAutoRedirect { get { throw null; } set { } }
333333
public System.Net.DecompressionMethods AutomaticDecompression { get { throw null; } set { } }
334-
public System.Net.Connections.ConnectionFactory? ConnectionFactory { get { throw null; } set { } }
335334
public System.TimeSpan ConnectTimeout { get { throw null; } set { } }
336335
[System.Diagnostics.CodeAnalysis.AllowNullAttribute]
337336
public System.Net.CookieContainer CookieContainer { get { throw null; } set { } }
@@ -345,7 +344,6 @@ public SocketsHttpHandler() { }
345344
public int MaxConnectionsPerServer { get { throw null; } set { } }
346345
public int MaxResponseDrainSize { get { throw null; } set { } }
347346
public int MaxResponseHeadersLength { get { throw null; } set { } }
348-
public System.Func<System.Net.Http.HttpRequestMessage, System.Net.Connections.Connection, System.Threading.CancellationToken, System.Threading.Tasks.ValueTask<System.Net.Connections.Connection>>? PlaintextFilter { get { throw null; } set { } }
349347
public System.TimeSpan PooledConnectionIdleTimeout { get { throw null; } set { } }
350348
public System.TimeSpan PooledConnectionLifetime { get { throw null; } set { } }
351349
public bool PreAuthenticate { get { throw null; } set { } }

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<ProjectReference Include="..\..\System.Runtime\ref\System.Runtime.csproj" />
1111
<ProjectReference Include="..\..\System.Net.Primitives\ref\System.Net.Primitives.csproj" />
1212
<ProjectReference Include="..\..\System.Net.Sockets\ref\System.Net.Sockets.csproj" />
13-
<ProjectReference Include="..\..\System.Net.Connections\ref\System.Net.Connections.csproj" />
1413
<ProjectReference Include="..\..\System.Net.Security\ref\System.Net.Security.csproj" />
1514
<ProjectReference Include="..\..\System.Security.Cryptography.X509Certificates\ref\System.Security.Cryptography.X509Certificates.csproj" />
1615
<ProjectReference Include="..\..\System.Text.Encoding\ref\System.Text.Encoding.csproj" />

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,6 @@
110110
Link="Common\System\IO\StreamHelpers.CopyValidation.cs" />
111111
<Compile Include="$(CommonPath)System\Net\Security\SslClientAuthenticationOptionsExtensions.cs"
112112
Link="Common\System\Net\Security\SslClientAuthenticationOptionsExtensions.cs" />
113-
<Compile Include="$(CommonPath)System\Net\NetworkErrorHelper.cs"
114-
Link="Common\System\Net\NetworkErrorHelper.cs" />
115113
<Compile Include="$(CommonPath)System\IO\DelegatingStream.cs"
116114
Link="Common\System\IO\DelegatingStream.cs" />
117115
<Compile Include="$(CommonPath)System\IO\ReadOnlyMemoryStream.cs"
@@ -175,9 +173,9 @@
175173
<Compile Include="System\Net\Http\SocketsHttpHandler\MultiProxy.cs" />
176174
<Compile Include="System\Net\Http\SocketsHttpHandler\RawConnectionStream.cs" />
177175
<Compile Include="System\Net\Http\SocketsHttpHandler\RedirectHandler.cs" />
176+
<Compile Include="System\Net\Http\SocketsHttpHandler\SocketsConnectionFactory.cs" />
178177
<Compile Include="System\Net\Http\SocketsHttpHandler\SocketsHttpHandler.cs" />
179178
<Compile Include="System\Net\Http\SocketsHttpHandler\SystemProxyInfo.cs" />
180-
<Compile Include="System\Net\Http\SocketsHttpHandler\DnsEndPointWithProperties.cs" />
181179
<Compile Include="$(CommonPath)System\Net\NTAuthentication.Common.cs"
182180
Link="Common\System\Net\NTAuthentication.Common.cs" />
183181
<Compile Include="$(CommonPath)System\Net\ContextFlagsPal.cs"
@@ -686,9 +684,7 @@
686684
<Reference Include="System.Diagnostics.DiagnosticSource" />
687685
<Reference Include="System.Diagnostics.Tracing" />
688686
<Reference Include="System.IO.Compression" />
689-
<Reference Include="System.IO.Pipelines" />
690687
<Reference Include="System.Memory" />
691-
<Reference Include="System.Net.Connections" />
692688
<Reference Include="System.Net.NameResolution" />
693689
<Reference Include="System.Net.NetworkInformation" />
694690
<Reference Include="System.Net.Primitives" />

0 commit comments

Comments
 (0)