Skip to content
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

Obsolete Socket.UseOnlyOverlappedIO #52475

Merged
merged 6 commits into from
May 18, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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
4 changes: 4 additions & 0 deletions src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ public Socket(System.Net.Sockets.SocketType socketType, System.Net.Sockets.Proto
[System.ObsoleteAttribute("SupportsIPv6 is obsoleted for this type, please use OSSupportsIPv6 instead. https://go.microsoft.com/fwlink/?linkid=14202")]
public static bool SupportsIPv6 { get { throw null; } }
public short Ttl { get { throw null; } set { } }
[System.ObsoleteAttribute("This property has no effect in .NET Core")]
hrrrrustic marked this conversation as resolved.
Show resolved Hide resolved
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public bool UseOnlyOverlappedIO { get { throw null; } set { } }
public System.Net.Sockets.Socket Accept() { throw null; }
public System.Threading.Tasks.Task<System.Net.Sockets.Socket> AcceptAsync() { throw null; }
Expand Down Expand Up @@ -501,6 +503,8 @@ public enum SocketInformationOptions
NonBlocking = 1,
Connected = 2,
Listening = 4,
[System.ObsoleteAttribute("This flag has no effect in .NET Core")]
hrrrrustic marked this conversation as resolved.
Show resolved Hide resolved
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
UseOnlyOverlappedIO = 8,
}
public enum SocketOptionLevel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
Expand Down Expand Up @@ -415,6 +416,8 @@ public bool Blocking
// allowing calls to DuplicateAndClose() even after performing asynchronous IO.
// .NET (Core) Windows sockets are entirely IOCP-based, and the concept of "overlapped IO"
// does not exist on other platforms, therefore UseOnlyOverlappedIO is a dummy, compat-only property.
[Obsolete("This property has no effect in .NET Core")]
hrrrrustic marked this conversation as resolved.
Show resolved Hide resolved
[EditorBrowsable(EditorBrowsableState.Never)]
public bool UseOnlyOverlappedIO
{
get { return false; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.ComponentModel;

namespace System.Net.Sockets
{
[Flags]
Expand All @@ -11,6 +13,8 @@ public enum SocketInformationOptions
//disconnect doesn't update getpeername to return a failure.
Connected = 0x2,
Listening = 0x4,
[Obsolete("This flag has no effect in .NET Core")]
hrrrrustic marked this conversation as resolved.
Show resolved Hide resolved
[EditorBrowsable(EditorBrowsableState.Never)]
UseOnlyOverlappedIO = 0x8,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,9 @@ public void Ctor_SafeHandle_BasicPropertiesPropagate_Success(AddressFamily addre
Assert.Equal(orig.ReceiveTimeout, copy.ReceiveTimeout);
Assert.Equal(orig.SendBufferSize, copy.SendBufferSize);
Assert.Equal(orig.SendTimeout, copy.SendTimeout);
#pragma warning disable 0618
Assert.Equal(orig.UseOnlyOverlappedIO, copy.UseOnlyOverlappedIO);
#pragma warning restore 0618
}

[Theory]
Expand Down Expand Up @@ -422,7 +424,6 @@ public async Task Ctor_SafeHandle_Tcp_SendReceive_Success(AddressFamily addressF
Assert.Equal(orig.SendBufferSize, client.SendBufferSize);
Assert.Equal(orig.SendTimeout, client.SendTimeout);
Assert.Equal(orig.Ttl, client.Ttl);
Assert.Equal(orig.UseOnlyOverlappedIO, client.UseOnlyOverlappedIO);

// Validate setting various properties on the new instance and seeing them roundtrip back to the original.
client.ReceiveTimeout = 42;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace System.Net.Sockets.Tests
{
// Test cases for DuplicateAndClose, Socket(socketInformation), Socket.UseOnlyOverlappedIO,
// Test cases for DuplicateAndClose, Socket(socketInformation), Socket(socketInformation),
hrrrrustic marked this conversation as resolved.
Show resolved Hide resolved
// and asynchronous IO behavior for duplicate sockets.
// Since the constructor Socket(socketInformation) is strongly coupled
// with the rest of the duplication logic, it's being tested here instead of CreateSocketTests.
Expand All @@ -32,9 +32,11 @@ public void UseOnlyOverlappedIO_AlwaysFalse()
{
using Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

#pragma warning disable 0618
Assert.False(s.UseOnlyOverlappedIO);
s.UseOnlyOverlappedIO = true;
Copy link
Member

Choose a reason for hiding this comment

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

We need to keep some of the tests around, with the warning disabled around the use in tests.

We need to make sure that it still works as expected even once it is obsolete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How can I add pragma warning disable without diagnstic id?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I can use CS0618
Okay, I'll return tests 👍

Copy link
Member

Choose a reason for hiding this comment

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

Assert.False(s.UseOnlyOverlappedIO);
#pragma warning restore 0618
}

[PlatformSpecific(TestPlatforms.Windows)]
Expand Down