Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ public ValueTask SendFileAsync(string? fileName, ReadOnlyMemory<byte> preBuffer,

if (!IsConnectionOriented)
{
var soex = new SocketException((int)SocketError.NotConnected);
return ValueTask.FromException(soex);
var ex = new NotSupportedException(SR.net_notconnected);
return ValueTask.FromException(ex);
}

int packetsCount = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ public void SendFile(string? fileName, ReadOnlySpan<byte> preBuffer, ReadOnlySpa
{
ThrowIfDisposed();

if (!Connected)
if (!IsConnectionOriented || !Connected)
{
throw new NotSupportedException(SR.net_notconnected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public async Task FileDoesNotExist_ThrowsFileNotFoundException(bool useOverloadW
[Theory]
[InlineData(false)]
[InlineData(true)]
[PlatformSpecific(TestPlatforms.Windows)]
public async Task UdpConnection_ThrowsException(bool usePreAndPostbufferOverload)
{
// Create file to send
Expand All @@ -77,16 +76,14 @@ public async Task UdpConnection_ThrowsException(bool usePreAndPostbufferOverload

client.Connect(listener.LocalEndPoint);

SocketException ex;
if (usePreAndPostbufferOverload)
{
ex = await Assert.ThrowsAsync<SocketException>(() => SendFileAsync(client, tempFile.Path, Array.Empty<byte>(), Array.Empty<byte>(), TransmitFileOptions.UseDefaultWorkerThread));
await Assert.ThrowsAsync<NotSupportedException>(() => SendFileAsync(client, tempFile.Path, Array.Empty<byte>(), Array.Empty<byte>(), TransmitFileOptions.UseDefaultWorkerThread));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test case should not be [PlatformSpecific(TestPlatforms.Windows)] anymore.

}
else
{
ex = await Assert.ThrowsAsync<SocketException>(() => SendFileAsync(client, tempFile.Path));
await Assert.ThrowsAsync<NotSupportedException>(() => SendFileAsync(client, tempFile.Path));
}
Assert.Equal(SocketError.NotConnected, ex.SocketErrorCode);
}

public static IEnumerable<object[]> SendFile_MemberData()
Expand Down