-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial (partially-reviewed API) System.Net.Connections. #39524
Conversation
Tagging subscribers to this area: @dotnet/ncl |
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
CC @JamesNK |
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
...aries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Connections/SocketConnection.cs
Outdated
Show resolved
Hide resolved
...aries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Connections/SocketConnection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with few comments.
But I'm not the expert on this.
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/ConnectionBase.cs
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/ConnectionExtensions.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPool.cs
Outdated
Show resolved
Hide resolved
cc: @safern for any of the build changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a look at the build changes
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System/Net/Connections/Connection.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj
Outdated
Show resolved
Hide resolved
1b2bcb0
to
8857dff
Compare
Yeah, I'll look at this in the morning as these kind of changes need file navigation and in the phone is not ideal. Count on my review tomorrow morning 😊 |
src/libraries/System.Net.Connections/src/System.Net.Connections.csproj
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Connections/src/System.Net.Connections.csproj
Outdated
Show resolved
Hide resolved
Note to myself, this will conflict with #35606. If you are in first I need to react, otherwise you by declaring that the library is part of the shared framework in a different file. |
7e04d47
to
9ac99db
Compare
src/libraries/System.Net.Connections/src/System/Net/Connections/ConnectionExtensions.cs
Outdated
Show resolved
Hide resolved
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
MVP ✌🏾 |
51b0730
to
ceea158
Compare
819a06a
to
244c6e3
Compare
244c6e3
to
ed9ce80
Compare
/azp run runtime-libraries outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
@scalablecory Will it be available as a .NET Standard nuget? |
This comment has been minimized.
This comment has been minimized.
@karelz, it isn't. SocketsHttpHandler is one consumer of the APIs. |
OK, sorry for the wrong answer then, I'll hide my reply to avoid further confusion and let others answer ... |
If you have use cases for this as a .NET Standard package, please open a new issue so we can gauge interest and discuss further. No concrete plans to announce here but we have been discussing this. Specifically, @davidfowl indicated interest to use this in the .NET Standard SignalR client library. Note - even if these core abstractions make it into a package, HttpClient's support for it will still only be in .NET 5. |
@@ -11,6 +11,7 @@ | |||
</ProjectReference> | |||
<ProjectReference Include="..\src\System.IO.Pipelines.csproj" /> | |||
<HarvestIncludePaths Include="lib/netstandard1.3" /> | |||
<InboxOnTargetFramework Include="net5.0" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bad. Don't do this. It freezes the API. Either stop producing the package, or treat it as OOB if you still want to control the API like an OOB (EG: System.Text.Json, ImmutableCollections, etc.) I'd recommend the latter. Go check how we package System.Text.Json for an example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be doing the latter. It's just like System.Text.Json etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @geoffkizer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I went ahead and submitted a fix for this: #40212
namespace System.Net.Connections | ||
{ | ||
/// <summary> | ||
/// A connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include more descriptive docs?
|
||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) | ||
{ | ||
if (buffer == null) return Task.FromException<int>(ExceptionDispatchInfo.SetCurrentStackTrace(new ArgumentNullException(nameof(buffer)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Argument exceptions should just be thrown rather than stored into the returned task.
Stream stream = tunnelResponse.Content.ReadAsStream(cancellationToken); | ||
EndPoint remoteEndPoint = new DnsEndPoint(_originAuthority.IdnHost, _originAuthority.Port); | ||
|
||
// TODO: the Socket from the response can be funneled into a connection property here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there an issue tracking this?
{ | ||
if (options == null || !options.TryGet(out DnsEndPointWithProperties? httpOptions)) | ||
{ | ||
return ValueTask.FromException<Connection>(ExceptionDispatchInfo.SetCurrentStackTrace(new HttpRequestException($"{nameof(SocketsHttpConnectionFactory)} requires a {nameof(DnsEndPointWithProperties)} property."))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SetCurrentStackTrace is really only useful when we expect the call chain and the await chain to be different, e.g. if an exception occurs, is stored into a field, and is then later thrown from that field. Here, presumably we expect the 99% case to be await ConnectAsync(...)
, in which case the SetCurrentStackTrace here is not only unnecessary.
This implements the already reviewed APIs of #1793. Followup PR will implement the Socket factories, otherwise this should match reviewed APIs.
Adds:
Makes these changes to existing code:
TODO: