Skip to content

Commit

Permalink
Obsolete Socket.UseOnlyOverlappedIO (#52475)
Browse files Browse the repository at this point in the history
close #47163
  • Loading branch information
hrrrrustic committed May 18, 2021
1 parent bbc054c commit 7be77b8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 1 deletion.
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 5+ and .NET Core.")]
[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 @@ -505,6 +507,8 @@ public enum SocketInformationOptions
NonBlocking = 1,
Connected = 2,
Listening = 4,
[System.ObsoleteAttribute("This flag has no effect in .NET 5+ and .NET Core.")]
[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 5+ and .NET Core.")]
[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 5+ and .NET Core.")]
[EditorBrowsable(EditorBrowsableState.Never)]
UseOnlyOverlappedIO = 0x8,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,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 @@ -424,7 +426,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 @@ -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;
Assert.False(s.UseOnlyOverlappedIO);
#pragma warning restore 0618
}

[PlatformSpecific(TestPlatforms.Windows)]
Expand Down

0 comments on commit 7be77b8

Please sign in to comment.