-
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
Added Span overloads for Socket.SendFile #47230
Conversation
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. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsFixes #43846 This PR is split-out of #45132 -- see #45132 (comment) for context.
|
src/libraries/System.Net.Sockets/src/System/Net/Sockets/Socket.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketPal.Windows.cs
Show resolved
Hide resolved
Tests? |
Tests for the array-based implementation are there, and as these forward to the span-based implementation that's covered. |
We should add explicit span tests too. Yeah it's duplicative, but that's fine; better to be duplicative than to miss something. |
To support all the refactoring described in #45132 (comment) and #43845, we should refactor I strongly suggest to do it in this PR. |
@antonfirsov the refactoring of the tests makes sense, but can this be done in a different PR? I'd like to focus this PR on adding the span-overloads. And maybe the major reason for my pushback is, that I'm not familiar with
I see #46862 and other code that uses the SocketTestHelperBase<T> but this doesn't make it sound for that change.Maybe I'm missing a trivial piece of the puzzle now, or we have to do this separately. |
@gfoidl
What I wanted was to avoid bloating the current |
Thanks for the explaination!
to see how it's done (and use that knowledge then for the SendFileAsync tests). |
I'm fine to defer the |
ok -- are we ready to merge then? @antonfirsov any remaining concerns? |
I have no more changes planned for this PR. So ready to merge from my side. |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
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. I have some comments regarding tests, but let's ignore them, since it doesn't make sense to do alterations to test code we are about to completely refactor anyways.
I want to merge as soon as the outerloop run finishes.
Assert.Throws<NotSupportedException>(() => s.BeginSendFile(null, null, null)); | ||
Assert.Throws<NotSupportedException>(() => s.BeginSendFile(null, null, null, TransmitFileOptions.UseDefaultWorkerThread, null, null)); | ||
} | ||
} | ||
|
||
[ConditionalTheory] |
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.
[PlatformSpecific]
is enough to make this conditional, [ConditionalTheory]
is used when you need to evaluate bool
members at runtime.
|
||
if (useAsync) | ||
{ | ||
await Assert.ThrowsAsync<SocketException>(() => Task.Factory.FromAsync<string>(client.BeginSendFile, client.EndSendFile, filename, null)); |
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.
Wouldn't it make sense to also check SocketException.SocketErrorCode
?
/// <exception cref="ObjectDisposedException">The <see cref="Socket"/> object has been closed.</exception> | ||
/// <exception cref="NotSupportedException">The <see cref="Socket"/> object is not connected to a remote host.</exception> | ||
/// <exception cref="InvalidOperationException">The <see cref="Socket"/> object is not in blocking mode and cannot accept this synchronous call.</exception> | ||
/// <exception cref="FileNotFoundException">The file <paramref name="fileName"/> was not found.</exception> |
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.
Looks like we don't have test for the FileNotFoundException
case.
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.
Indeed, that's missing.
As the tests will be refactored, should we file an issue for this and where these points get collected? Or won't we forget about this anyway?
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.
If one of us manages to PR the test refactor within a week, I wouldn't bother with an issue, otherwise it would be wise to start tracking it.
My main fear is that more extensive testing will discover a bunch of corner cases and platform inconsistencies (or even actual bugs) we'll have to deal with. This is what made things hard with my other PR.
OuterLoop test failures are unrelated: |
@gfoidl FYI I have started refactoring the SendFile tests, if everything goes well, expect a PR within a day. |
Thanks for the update -- happy to have a look at the PR (then start the async versions of sendfile). |
Refactor tests in SendFile.cs to utilize SocketTestHelper<T> As a result cover some cases which were uncovered before (for example Dispose VS async). Add more checks and tests as discussed in #47230.
Fixes #43846
This PR is split-out of #45132 -- see #45132 (comment) for context.