From: Eric Erhardt Date: Thu, 27 Feb 2020 03:19:18 +0000 (-0600) Subject: Annotate System.Net.Sockets for nullable reference types (#32675) X-Git-Tag: submit/tizen/20210909.063632~9470 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e22cf553e11d500c1523034f2c7ff745014e0629;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Annotate System.Net.Sockets for nullable reference types (#32675) * All AsyncResult classes have nullable enable. * Most ancillary files annotated. * UdpClient annotated * Annotate TcpClient * Annotate TcpListener, SafeSocketHandle, SocketTaskExtensions * Annotate NetworkStream and SendPacketsElement * Annotate SocketPal. * Annotate SocketAsyncEventArgs * Annotate SocketAsyncEngine and Context on Unix * Annotate Socket.Tasks * Finish annotating the Socket class. * Remove inline #nullable lines * Annotate all public methods. * Sync up to latest code and cleanup. * Fix .NET Framework build for WinHttpHandler. --- diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs index e9cffa9..d11bdfb 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.TransmitFile.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System; using System.Net.Sockets; using System.Runtime.InteropServices; @@ -14,7 +15,7 @@ internal static partial class Interop [DllImport(Interop.Libraries.Mswsock, SetLastError = true)] internal static extern unsafe bool TransmitFile( SafeHandle socket, - SafeHandle fileHandle, + SafeHandle? fileHandle, int numberOfBytesToWrite, int numberOfBytesPerSend, NativeOverlapped* overlapped, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs index cb319d9..634091a 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.WSAIoctl.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System; using System.Net.Sockets; using System.Runtime.InteropServices; @@ -27,9 +28,9 @@ internal static partial class Interop internal static extern SocketError WSAIoctl_Blocking( SafeSocketHandle socketHandle, [In] int ioControlCode, - [In] byte[] inBuffer, + [In] byte[]? inBuffer, [In] int inBufferSize, - [Out] byte[] outBuffer, + [Out] byte[]? outBuffer, [In] int outBufferSize, [Out] out int bytesTransferred, [In] IntPtr overlapped, diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs index df3c9db..9bd2533 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/Interop.setsockopt.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System; using System.Net.Sockets; using System.Runtime.InteropServices; @@ -31,7 +32,7 @@ internal static partial class Interop [In] SafeSocketHandle socketHandle, [In] SocketOptionLevel optionLevel, [In] SocketOptionName optionName, - [In] byte[] optionValue, + [In] byte[]? optionValue, [In] int optionLength); [DllImport(Interop.Libraries.Ws2_32, SetLastError = true)] diff --git a/src/libraries/Common/src/Interop/Windows/WinSock/SafeNativeOverlapped.cs b/src/libraries/Common/src/Interop/Windows/WinSock/SafeNativeOverlapped.cs index 32e395f..b1bf965 100644 --- a/src/libraries/Common/src/Interop/Windows/WinSock/SafeNativeOverlapped.cs +++ b/src/libraries/Common/src/Interop/Windows/WinSock/SafeNativeOverlapped.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; using System.Runtime.InteropServices; using System.Threading; @@ -12,7 +13,7 @@ namespace System.Net.Sockets { internal sealed class SafeNativeOverlapped : SafeHandle { - private readonly SafeSocketHandle _socketHandle; + private readonly SafeSocketHandle? _socketHandle; private SafeNativeOverlapped() : this(IntPtr.Zero) @@ -59,7 +60,7 @@ namespace System.Net.Sockets { Debug.Assert(_socketHandle != null, "_socketHandle is null."); - ThreadPoolBoundHandle boundHandle = _socketHandle.IOCPBoundHandle; + ThreadPoolBoundHandle? boundHandle = _socketHandle.IOCPBoundHandle; Debug.Assert(boundHandle != null, "SafeNativeOverlapped::FreeNativeOverlapped - boundHandle is null"); // FreeNativeOverlapped will be called even if boundHandle was previously disposed. diff --git a/src/libraries/Common/src/System/Net/ContextAwareResult.Windows.cs b/src/libraries/Common/src/System/Net/ContextAwareResult.Windows.cs index acbdfe5..2dc2c65 100644 --- a/src/libraries/Common/src/System/Net/ContextAwareResult.Windows.cs +++ b/src/libraries/Common/src/System/Net/ContextAwareResult.Windows.cs @@ -2,13 +2,14 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Security.Principal; namespace System.Net { internal partial class ContextAwareResult { - private WindowsIdentity _windowsIdentity; + private WindowsIdentity? _windowsIdentity; // Security: We need an assert for a call into WindowsIdentity.GetCurrent. private void SafeCaptureIdentity() diff --git a/src/libraries/Common/src/System/Net/ContextAwareResult.cs b/src/libraries/Common/src/System/Net/ContextAwareResult.cs index f17b985..b143be3 100644 --- a/src/libraries/Common/src/System/Net/ContextAwareResult.cs +++ b/src/libraries/Common/src/System/Net/ContextAwareResult.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Threading; namespace System.Net @@ -20,8 +21,8 @@ namespace System.Net // to have several pending IOs differentiated by their state object. We don't want that pattern to break the cache. internal class CallbackClosure { - private readonly AsyncCallback _savedCallback; - private readonly ExecutionContext _savedContext; + private readonly AsyncCallback? _savedCallback; + private readonly ExecutionContext? _savedContext; internal CallbackClosure(ExecutionContext context, AsyncCallback callback) { @@ -32,7 +33,7 @@ namespace System.Net } } - internal bool IsCompatible(AsyncCallback callback) + internal bool IsCompatible(AsyncCallback? callback) { if (callback == null || _savedCallback == null) { @@ -49,7 +50,7 @@ namespace System.Net return true; } - internal AsyncCallback AsyncCallback + internal AsyncCallback? AsyncCallback { get { @@ -57,7 +58,7 @@ namespace System.Net } } - internal ExecutionContext Context + internal ExecutionContext? Context { get { @@ -82,12 +83,12 @@ namespace System.Net } // This needs to be volatile so it's sure to make it over to the completion thread in time. - private volatile ExecutionContext _context; - private object _lock; + private volatile ExecutionContext? _context; + private object? _lock; private StateFlags _flags; - internal ContextAwareResult(object myObject, object myState, AsyncCallback myCallBack) : + internal ContextAwareResult(object myObject, object? myState, AsyncCallback? myCallBack) : this(false, false, myObject, myState, myCallBack) { } @@ -97,11 +98,11 @@ namespace System.Net // // Setting forceCaptureContext enables the ContextCopy property even when a null callback is specified. (The context is // always captured if a callback is given.) - internal ContextAwareResult(bool captureIdentity, bool forceCaptureContext, object myObject, object myState, AsyncCallback myCallBack) : + internal ContextAwareResult(bool captureIdentity, bool forceCaptureContext, object myObject, object? myState, AsyncCallback? myCallBack) : this(captureIdentity, forceCaptureContext, false, myObject, myState, myCallBack) { } - internal ContextAwareResult(bool captureIdentity, bool forceCaptureContext, bool threadSafeContextCopy, object myObject, object myState, AsyncCallback myCallBack) : + internal ContextAwareResult(bool captureIdentity, bool forceCaptureContext, bool threadSafeContextCopy, object myObject, object? myState, AsyncCallback? myCallBack) : base(myObject, myState, myCallBack) { if (forceCaptureContext) @@ -124,7 +125,7 @@ namespace System.Net // May block briefly if the context is still being produced. // // Returns null if called from the posting thread. - internal ExecutionContext ContextCopy + internal ExecutionContext? ContextCopy { get { @@ -138,7 +139,7 @@ namespace System.Net throw new InvalidOperationException(SR.net_completed_result); } - ExecutionContext context = _context; + ExecutionContext? context = _context; if (context != null) { return context; // No need to copy on CoreCLR; ExecutionContext is immutable @@ -189,13 +190,13 @@ namespace System.Net internal object StartPostingAsyncOp() { - return StartPostingAsyncOp(true); + return StartPostingAsyncOp(true)!; } // If ContextCopy or Identity will be used, the return value should be locked until FinishPostingAsyncOp() is called // or the operation has been aborted (e.g. by BeginXxx throwing). Otherwise, this can be called with false to prevent the lock // object from being created. - internal object StartPostingAsyncOp(bool lockCapture) + internal object? StartPostingAsyncOp(bool lockCapture) { if (InternalPeekCompleted) { @@ -220,13 +221,13 @@ namespace System.Net _flags |= StateFlags.PostBlockFinished; - ExecutionContext cachedContext = null; + ExecutionContext? cachedContext = null; return CaptureOrComplete(ref cachedContext, false); } // Call this when returning control to the user. Allows a cached Callback Closure to be supplied and used // as appropriate, and replaced with a new one. - internal bool FinishPostingAsyncOp(ref CallbackClosure closure) + internal bool FinishPostingAsyncOp(ref CallbackClosure? closure) { // Ignore this call if StartPostingAsyncOp() failed or wasn't called, or this has already been called. if ((_flags & (StateFlags.PostBlockStarted | StateFlags.PostBlockFinished)) != StateFlags.PostBlockStarted) @@ -237,8 +238,8 @@ namespace System.Net _flags |= StateFlags.PostBlockFinished; // Need a copy of this ref argument since it can be used in many of these calls simultaneously. - CallbackClosure closureCopy = closure; - ExecutionContext cachedContext; + CallbackClosure? closureCopy = closure; + ExecutionContext? cachedContext; if (closureCopy == null) { cachedContext = null; @@ -283,7 +284,7 @@ namespace System.Net // called. // // Returns whether the operation completed sync or not. - private bool CaptureOrComplete(ref ExecutionContext cachedContext, bool returnContext) + private bool CaptureOrComplete(ref ExecutionContext? cachedContext, bool returnContext) { if ((_flags & StateFlags.PostBlockStarted) == 0) { @@ -374,7 +375,7 @@ namespace System.Net return; } - ExecutionContext context = _context; + ExecutionContext? context = _context; // If the context is being abandoned or wasn't captured (SuppressFlow, null AsyncCallback), just // complete regularly, as long as CaptureOrComplete() has finished. @@ -385,7 +386,7 @@ namespace System.Net return; } - ExecutionContext.Run(context, s => ((ContextAwareResult)s).CompleteCallback(), this); + ExecutionContext.Run(context, s => ((ContextAwareResult)s!).CompleteCallback(), this); } private void CompleteCallback() @@ -394,6 +395,6 @@ namespace System.Net base.Complete(IntPtr.Zero); } - internal virtual EndPoint RemoteEndPoint => null; + internal virtual EndPoint? RemoteEndPoint => null; } } diff --git a/src/libraries/Common/src/System/Net/DebugSafeHandleMinusOneIsInvalid.cs b/src/libraries/Common/src/System/Net/DebugSafeHandleMinusOneIsInvalid.cs index f56a08b..5cf3352 100644 --- a/src/libraries/Common/src/System/Net/DebugSafeHandleMinusOneIsInvalid.cs +++ b/src/libraries/Common/src/System/Net/DebugSafeHandleMinusOneIsInvalid.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using Microsoft.Win32.SafeHandles; namespace System.Net @@ -13,7 +14,7 @@ namespace System.Net // internal abstract class DebugSafeHandleMinusOneIsInvalid : SafeHandleMinusOneIsInvalid { - private string _trace; + private string _trace = null!; // initialized by helper called from ctor protected DebugSafeHandleMinusOneIsInvalid(bool ownsHandle) : base(ownsHandle) { diff --git a/src/libraries/Common/src/System/Net/Internals/SocketExceptionFactory.cs b/src/libraries/Common/src/System/Net/Internals/SocketExceptionFactory.cs index 217ff1a..fab19ad 100644 --- a/src/libraries/Common/src/System/Net/Internals/SocketExceptionFactory.cs +++ b/src/libraries/Common/src/System/Net/Internals/SocketExceptionFactory.cs @@ -13,7 +13,7 @@ namespace System.Net.Internals { private readonly EndPoint? _endPoint; - public ExtendedSocketException(int errorCode, EndPoint endPoint) + public ExtendedSocketException(int errorCode, EndPoint? endPoint) : base(errorCode) { _endPoint = endPoint; @@ -29,7 +29,7 @@ namespace System.Net.Internals (_endPoint == null) ? base.Message : base.Message + " " + _endPoint.ToString(); } - public static SocketException CreateSocketException(int socketError, EndPoint endPoint) + public static SocketException CreateSocketException(int socketError, EndPoint? endPoint) { return new ExtendedSocketException(socketError, endPoint); } diff --git a/src/libraries/Common/src/System/Net/LazyAsyncResult.cs b/src/libraries/Common/src/System/Net/LazyAsyncResult.cs index 54847f7..20d9557 100644 --- a/src/libraries/Common/src/System/Net/LazyAsyncResult.cs +++ b/src/libraries/Common/src/System/Net/LazyAsyncResult.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. +#nullable enable using System.Diagnostics; using System.Threading; using System.Threading.Tasks; @@ -17,13 +18,13 @@ namespace System.Net // This is to avoid user mistakes when they queue another async op from a callback the completes sync. [ThreadStatic] - private static ThreadContext t_threadContext; + private static ThreadContext? t_threadContext; private static ThreadContext CurrentThreadContext { get { - ThreadContext threadContext = t_threadContext; + ThreadContext? threadContext = t_threadContext; if (threadContext == null) { threadContext = new ThreadContext(); @@ -40,14 +41,14 @@ namespace System.Net } #if DEBUG - internal object _debugAsyncChain = null; // Optionally used to track chains of async calls. + internal object? _debugAsyncChain = null; // Optionally used to track chains of async calls. private bool _protectState; // Used by ContextAwareResult to prevent some calls. #endif private readonly object _asyncObject; // Caller's async object. - private readonly object _asyncState; // Caller's state object. - private AsyncCallback _asyncCallback; // Caller's callback method. - private object _result; // Final IO result to be returned byt the End*() method. + private readonly object? _asyncState; // Caller's state object. + private AsyncCallback? _asyncCallback; // Caller's callback method. + private object? _result; // Final IO result to be returned byt the End*() method. private int _errorCode; // Win32 error code for Win32 IO async calls (that want to throw). private int _intCompleted; // Sign bit indicates synchronous completion if set. // Remaining bits count the number of InvokeCallbak() calls. @@ -55,9 +56,9 @@ namespace System.Net private bool _endCalled; // True if the user called the End*() method. private bool _userEvent; // True if the event has been (or is about to be) handed to the user - private object _event; // Lazy allocated event to be returned in the IAsyncResult for the client to wait on. + private object? _event; // Lazy allocated event to be returned in the IAsyncResult for the client to wait on. - internal LazyAsyncResult(object myObject, object myState, AsyncCallback myCallBack) + internal LazyAsyncResult(object myObject, object? myState, AsyncCallback? myCallBack) { _asyncObject = myObject; _asyncState = myState; @@ -76,7 +77,7 @@ namespace System.Net } // Interface method to return the caller's state object. - public object AsyncState + public object? AsyncState { get { @@ -84,7 +85,7 @@ namespace System.Net } } - protected AsyncCallback AsyncCallback + protected AsyncCallback? AsyncCallback { get { @@ -117,8 +118,6 @@ namespace System.Net } #endif - ManualResetEvent asyncEvent; - // Indicates that the user has seen the event; it can't be disposed. _userEvent = true; @@ -132,7 +131,7 @@ namespace System.Net // possible for _event to become null immediately after being set, but only if // IsCompleted has become true. Therefore it's possible for this property // to give different (set) events to different callers when IsCompleted is true. - asyncEvent = (ManualResetEvent)_event; + ManualResetEvent? asyncEvent = (ManualResetEvent?)_event; while (asyncEvent == null) { LazilyCreateEvent(out asyncEvent); @@ -253,7 +252,7 @@ namespace System.Net } // Internal property for setting the IO result. - internal object Result + internal object? Result { get { @@ -310,7 +309,7 @@ namespace System.Net // Used by derived classes to pass context into an overridden Complete(). Useful // for determining the 'winning' thread in case several may simultaneously call // the equivalent of InvokeCallback(). - protected void ProtectedInvokeCallback(object result, IntPtr userToken) + protected void ProtectedInvokeCallback(object? result, IntPtr userToken) { if (NetEventSource.IsEnabled) NetEventSource.Enter(this, result, userToken); @@ -334,7 +333,7 @@ namespace System.Net _result = result; } - ManualResetEvent asyncEvent = (ManualResetEvent)_event; + ManualResetEvent? asyncEvent = (ManualResetEvent?)_event; if (asyncEvent != null) { try @@ -353,7 +352,7 @@ namespace System.Net } // Completes the IO with a result and invoking the user's callback. - internal void InvokeCallback(object result) + internal void InvokeCallback(object? result) { ProtectedInvokeCallback(result, IntPtr.Zero); } @@ -384,7 +383,7 @@ namespace System.Net if (NetEventSource.IsEnabled) NetEventSource.Info(this, "*** OFFLOADED the user callback ****"); Task.Factory.StartNew( - s => WorkerThreadComplete(s), + s => WorkerThreadComplete(s!), this, CancellationToken.None, TaskCreationOptions.DenyChildAttach, @@ -422,7 +421,7 @@ namespace System.Net try { - thisPtr._asyncCallback(thisPtr); + thisPtr._asyncCallback!(thisPtr); } finally { @@ -437,21 +436,21 @@ namespace System.Net { } - internal object InternalWaitForCompletion() + internal object? InternalWaitForCompletion() { return WaitForCompletion(true); } - private object WaitForCompletion(bool snap) + private object? WaitForCompletion(bool snap) { - ManualResetEvent waitHandle = null; + ManualResetEvent? waitHandle = null; bool createdByMe = false; bool complete = snap ? IsCompleted : InternalPeekCompleted; if (!complete) { // Not done yet, so wait: - waitHandle = (ManualResetEvent)_event; + waitHandle = (ManualResetEvent?)_event; if (waitHandle == null) { createdByMe = LazilyCreateEvent(out waitHandle); @@ -477,11 +476,11 @@ namespace System.Net { // Does _userEvent need to be volatile (or _event set via Interlocked) in order // to avoid giving a user a disposed event? - ManualResetEvent oldEvent = (ManualResetEvent)_event; + ManualResetEvent? oldEvent = (ManualResetEvent?)_event; _event = null; if (!_userEvent) { - oldEvent.Dispose(); + oldEvent?.Dispose(); } } } diff --git a/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs b/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs index 46cd2ee..5d8d579 100644 --- a/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs +++ b/src/libraries/Common/src/System/Net/Logging/NetEventSource.Common.cs @@ -11,6 +11,7 @@ #nullable enable using System.Collections; using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; using System.Diagnostics.Tracing; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -125,7 +126,7 @@ namespace System.Net /// The second object to log. /// The calling member. [NonEvent] - public static void Enter(object? thisOrContextObject, object arg0, object arg1, [CallerMemberName] string? memberName = null) + public static void Enter(object? thisOrContextObject, object? arg0, object arg1, [CallerMemberName] string? memberName = null) { DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); @@ -172,7 +173,7 @@ namespace System.Net /// A return value from the member. /// The calling member. [NonEvent] - public static void Exit(object? thisOrContextObject, object arg0, [CallerMemberName] string? memberName = null) + public static void Exit(object? thisOrContextObject, object? arg0, [CallerMemberName] string? memberName = null) { DebugValidateArg(thisOrContextObject); DebugValidateArg(arg0); @@ -264,6 +265,9 @@ namespace System.Net /// The message to be logged. /// The calling member. [NonEvent] +#if NETCOREAPP + [DoesNotReturn] +#endif public static void Fail(object? thisOrContextObject, FormattableString formattableString, [CallerMemberName] string? memberName = null) { // Don't call DebugValidateArg on args, as we expect Fail to be used in assert/failure situations @@ -278,6 +282,9 @@ namespace System.Net /// The message to be logged. /// The calling member. [NonEvent] +#if NETCOREAPP + [DoesNotReturn] +#endif public static void Fail(object? thisOrContextObject, object message, [CallerMemberName] string? memberName = null) { // Don't call DebugValidateArg on args, as we expect Fail to be used in assert/failure situations diff --git a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.Unix.cs b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.Unix.cs index 3025ee6..1176cd8 100644 --- a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.Unix.cs +++ b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/NamedPipeClientStream.Unix.cs @@ -28,7 +28,7 @@ namespace System.IO.Pipes SafePipeHandle? clientHandle = null; try { - socket.Connect(new UnixDomainSocketEndPoint(_normalizedPipePath)); + socket.Connect(new UnixDomainSocketEndPoint(_normalizedPipePath!)); clientHandle = new SafePipeHandle(socket); ConfigureSocket(socket, clientHandle, _direction, 0, 0, _inheritability); } diff --git a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs index fdd1d92..9da3770 100644 --- a/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs +++ b/src/libraries/System.IO.Pipes/src/System/IO/Pipes/PipeStream.Unix.cs @@ -183,7 +183,7 @@ namespace System.IO.Pipes try { - return await InternalHandle!.NamedPipeSocket.ReceiveAsync(destination, SocketFlags.None, cancellationToken).ConfigureAwait(false); + return await InternalHandle!.NamedPipeSocket!.ReceiveAsync(destination, SocketFlags.None, cancellationToken).ConfigureAwait(false); } catch (SocketException e) { @@ -199,7 +199,7 @@ namespace System.IO.Pipes { while (source.Length > 0) { - int bytesWritten = await _handle!.NamedPipeSocket.SendAsync(source, SocketFlags.None, cancellationToken).ConfigureAwait(false); + int bytesWritten = await _handle!.NamedPipeSocket!.SendAsync(source, SocketFlags.None, cancellationToken).ConfigureAwait(false); Debug.Assert(bytesWritten > 0 && bytesWritten <= source.Length); source = source.Slice(bytesWritten); } diff --git a/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs b/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs index 965e990..f2535d4 100644 --- a/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs +++ b/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.cs @@ -50,7 +50,7 @@ namespace System.Net.Sockets private int _dummyPrimitive; public System.Net.IPAddress Address { get { throw null; } } public int Interface { get { throw null; } } - public override bool Equals(object comparand) { throw null; } + public override bool Equals(object? comparand) { throw null; } public override int GetHashCode() { throw null; } public static bool operator ==(System.Net.Sockets.IPPacketInformation packetInformation1, System.Net.Sockets.IPPacketInformation packetInformation2) { throw null; } public static bool operator !=(System.Net.Sockets.IPPacketInformation packetInformation1, System.Net.Sockets.IPPacketInformation packetInformation2) { throw null; } @@ -82,7 +82,7 @@ namespace System.Net.Sockets public MulticastOption(System.Net.IPAddress group, System.Net.IPAddress mcint) { } public System.Net.IPAddress Group { get { throw null; } set { } } public int InterfaceIndex { get { throw null; } set { } } - public System.Net.IPAddress LocalAddress { get { throw null; } set { } } + public System.Net.IPAddress? LocalAddress { get { throw null; } set { } } } public partial class NetworkStream : System.IO.Stream { @@ -102,8 +102,8 @@ namespace System.Net.Sockets public System.Net.Sockets.Socket Socket { get { throw null; } } protected bool Writeable { get { throw null; } set { } } public override int WriteTimeout { get { throw null; } set { } } - public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) { throw null; } - public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int size, System.AsyncCallback callback, object state) { throw null; } + public override System.IAsyncResult BeginRead(byte[] buffer, int offset, int size, System.AsyncCallback? callback, object? state) { throw null; } + public override System.IAsyncResult BeginWrite(byte[] buffer, int offset, int size, System.AsyncCallback? callback, object? state) { throw null; } public void Close(int timeout) { } protected override void Dispose(bool disposing) { } public override int EndRead(System.IAsyncResult asyncResult) { throw null; } @@ -212,11 +212,11 @@ namespace System.Net.Sockets public SendPacketsElement(string filepath, int offset, int count, bool endOfPacket) { } public SendPacketsElement(string filepath, long offset, int count) { } public SendPacketsElement(string filepath, long offset, int count, bool endOfPacket) { } - public byte[] Buffer { get { throw null; } } + public byte[]? Buffer { get { throw null; } } public int Count { get { throw null; } } public bool EndOfPacket { get { throw null; } } - public string FilePath { get { throw null; } } - public System.IO.FileStream FileStream { get { throw null; } } + public string? FilePath { get { throw null; } } + public System.IO.FileStream? FileStream { get { throw null; } } public int Offset { get { throw null; } } public long OffsetLong { get { throw null; } } } @@ -235,8 +235,9 @@ namespace System.Net.Sockets public bool ExclusiveAddressUse { get { throw null; } set { } } public System.IntPtr Handle { get { throw null; } } public bool IsBound { get { throw null; } } - public System.Net.Sockets.LingerOption LingerState { get { throw null; } set { } } - public System.Net.EndPoint LocalEndPoint { get { throw null; } } + [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] + public System.Net.Sockets.LingerOption? LingerState { get { throw null; } set { } } + public System.Net.EndPoint? LocalEndPoint { get { throw null; } } public bool MulticastLoopback { get { throw null; } set { } } public bool NoDelay { get { throw null; } set { } } public static bool OSSupportsIPv4 { get { throw null; } } @@ -245,7 +246,7 @@ namespace System.Net.Sockets public System.Net.Sockets.ProtocolType ProtocolType { get { throw null; } } public int ReceiveBufferSize { get { throw null; } set { } } public int ReceiveTimeout { get { throw null; } set { } } - public System.Net.EndPoint RemoteEndPoint { get { throw null; } } + public System.Net.EndPoint? RemoteEndPoint { get { throw null; } } public System.Net.Sockets.SafeSocketHandle SafeHandle { get { throw null; } } public int SendBufferSize { get { throw null; } set { } } public int SendTimeout { get { throw null; } set { } } @@ -258,27 +259,27 @@ namespace System.Net.Sockets public bool UseOnlyOverlappedIO { get { throw null; } set { } } public System.Net.Sockets.Socket Accept() { throw null; } public bool AcceptAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; } - public System.IAsyncResult BeginAccept(System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginAccept(int receiveSize, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginAccept(System.Net.Sockets.Socket acceptSocket, int receiveSize, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginConnect(System.Net.EndPoint remoteEP, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginConnect(System.Net.IPAddress address, int port, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginConnect(System.Net.IPAddress[] addresses, int port, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginConnect(string host, int port, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginDisconnect(bool reuseSocket, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginReceive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginReceive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginReceive(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginReceive(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginReceiveFrom(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginReceiveMessageFrom(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSend(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSend(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSend(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSend(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSendFile(string fileName, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSendFile(string fileName, byte[] preBuffer, byte[] postBuffer, System.Net.Sockets.TransmitFileOptions flags, System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP, System.AsyncCallback callback, object state) { throw null; } + public System.IAsyncResult BeginAccept(System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginAccept(int receiveSize, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginAccept(System.Net.Sockets.Socket? acceptSocket, int receiveSize, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginConnect(System.Net.EndPoint remoteEP, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginConnect(System.Net.IPAddress address, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginConnect(System.Net.IPAddress[] addresses, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginConnect(string host, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginDisconnect(bool reuseSocket, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginReceive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult? BeginReceive(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginReceive(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult? BeginReceive(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginReceiveFrom(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginReceiveMessageFrom(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginSend(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult? BeginSend(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginSend(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult? BeginSend(System.Collections.Generic.IList> buffers, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginSendFile(string fileName, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginSendFile(string? fileName, byte[]? preBuffer, byte[]? postBuffer, System.Net.Sockets.TransmitFileOptions flags, System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP, System.AsyncCallback? callback, object? state) { throw null; } public void Bind(System.Net.EndPoint localEP) { } public static void CancelConnectAsync(System.Net.Sockets.SocketAsyncEventArgs e) { } public void Close() { } @@ -294,8 +295,8 @@ namespace System.Net.Sockets public void Dispose() { } protected virtual void Dispose(bool disposing) { } public System.Net.Sockets.SocketInformation DuplicateAndClose(int targetProcessId) { throw null; } - public System.Net.Sockets.Socket EndAccept(out byte[] buffer, System.IAsyncResult asyncResult) { throw null; } - public System.Net.Sockets.Socket EndAccept(out byte[] buffer, out int bytesTransferred, System.IAsyncResult asyncResult) { throw null; } + public System.Net.Sockets.Socket EndAccept(out byte[]? buffer, System.IAsyncResult asyncResult) { throw null; } + public System.Net.Sockets.Socket EndAccept(out byte[]? buffer, out int bytesTransferred, System.IAsyncResult asyncResult) { throw null; } public System.Net.Sockets.Socket EndAccept(System.IAsyncResult asyncResult) { throw null; } public void EndConnect(System.IAsyncResult asyncResult) { } public void EndDisconnect(System.IAsyncResult asyncResult) { } @@ -308,11 +309,11 @@ namespace System.Net.Sockets public void EndSendFile(System.IAsyncResult asyncResult) { } public int EndSendTo(System.IAsyncResult asyncResult) { throw null; } ~Socket() { } - public object GetSocketOption(System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName) { throw null; } + public object? GetSocketOption(System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName) { throw null; } public void GetSocketOption(System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, byte[] optionValue) { } public byte[] GetSocketOption(System.Net.Sockets.SocketOptionLevel optionLevel, System.Net.Sockets.SocketOptionName optionName, int optionLength) { throw null; } - public int IOControl(int ioControlCode, byte[] optionInValue, byte[] optionOutValue) { throw null; } - public int IOControl(System.Net.Sockets.IOControlCode ioControlCode, byte[] optionInValue, byte[] optionOutValue) { throw null; } + public int IOControl(int ioControlCode, byte[]? optionInValue, byte[]? optionOutValue) { throw null; } + public int IOControl(System.Net.Sockets.IOControlCode ioControlCode, byte[]? optionInValue, byte[]? optionOutValue) { throw null; } public void Listen() { } public void Listen(int backlog) { } public bool Poll(int microSeconds, System.Net.Sockets.SelectMode mode) { throw null; } @@ -335,7 +336,7 @@ namespace System.Net.Sockets public bool ReceiveFromAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; } public int ReceiveMessageFrom(byte[] buffer, int offset, int size, ref System.Net.Sockets.SocketFlags socketFlags, ref System.Net.EndPoint remoteEP, out System.Net.Sockets.IPPacketInformation ipPacketInformation) { throw null; } public bool ReceiveMessageFromAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; } - public static void Select(System.Collections.IList checkRead, System.Collections.IList checkWrite, System.Collections.IList checkError, int microSeconds) { } + public static void Select(System.Collections.IList? checkRead, System.Collections.IList? checkWrite, System.Collections.IList? checkError, int microSeconds) { } public int Send(byte[] buffer) { throw null; } public int Send(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags) { throw null; } public int Send(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode) { throw null; } @@ -349,7 +350,7 @@ namespace System.Net.Sockets public int Send(System.ReadOnlySpan buffer, System.Net.Sockets.SocketFlags socketFlags, out System.Net.Sockets.SocketError errorCode) { throw null; } public bool SendAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; } public void SendFile(string fileName) { } - public void SendFile(string fileName, byte[] preBuffer, byte[] postBuffer, System.Net.Sockets.TransmitFileOptions flags) { } + public void SendFile(string? fileName, byte[]? preBuffer, byte[]? postBuffer, System.Net.Sockets.TransmitFileOptions flags) { } public bool SendPacketsAsync(System.Net.Sockets.SocketAsyncEventArgs e) { throw null; } public int SendTo(byte[] buffer, int offset, int size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) { throw null; } public int SendTo(byte[] buffer, int size, System.Net.Sockets.SocketFlags socketFlags, System.Net.EndPoint remoteEP) { throw null; } @@ -367,30 +368,30 @@ namespace System.Net.Sockets { public SocketAsyncEventArgs() { } public SocketAsyncEventArgs(bool unsafeSuppressExecutionContextFlow) { } - public System.Net.Sockets.Socket AcceptSocket { get { throw null; } set { } } - public byte[] Buffer { get { throw null; } } - public System.Collections.Generic.IList> BufferList { get { throw null; } set { } } + public System.Net.Sockets.Socket? AcceptSocket { get { throw null; } set { } } + public byte[]? Buffer { get { throw null; } } + public System.Collections.Generic.IList>? BufferList { get { throw null; } set { } } public int BytesTransferred { get { throw null; } } - public System.Exception ConnectByNameError { get { throw null; } } - public System.Net.Sockets.Socket ConnectSocket { get { throw null; } } + public System.Exception? ConnectByNameError { get { throw null; } } + public System.Net.Sockets.Socket? ConnectSocket { get { throw null; } } public int Count { get { throw null; } } public bool DisconnectReuseSocket { get { throw null; } set { } } public System.Net.Sockets.SocketAsyncOperation LastOperation { get { throw null; } } public System.Memory MemoryBuffer { get { throw null; } } public int Offset { get { throw null; } } public System.Net.Sockets.IPPacketInformation ReceiveMessageFromPacketInfo { get { throw null; } } - public System.Net.EndPoint RemoteEndPoint { get { throw null; } set { } } - public System.Net.Sockets.SendPacketsElement[] SendPacketsElements { get { throw null; } set { } } + public System.Net.EndPoint? RemoteEndPoint { get { throw null; } set { } } + public System.Net.Sockets.SendPacketsElement[]? SendPacketsElements { get { throw null; } set { } } public System.Net.Sockets.TransmitFileOptions SendPacketsFlags { get { throw null; } set { } } public int SendPacketsSendSize { get { throw null; } set { } } public System.Net.Sockets.SocketError SocketError { get { throw null; } set { } } public System.Net.Sockets.SocketFlags SocketFlags { get { throw null; } set { } } - public object UserToken { get { throw null; } set { } } - public event System.EventHandler Completed { add { } remove { } } + public object? UserToken { get { throw null; } set { } } + public event System.EventHandler? Completed { add { } remove { } } public void Dispose() { } ~SocketAsyncEventArgs() { } protected virtual void OnCompleted(System.Net.Sockets.SocketAsyncEventArgs e) { } - public void SetBuffer(byte[] buffer, int offset, int count) { } + public void SetBuffer(byte[]? buffer, int offset, int count) { } public void SetBuffer(int offset, int count) { } public void SetBuffer(System.Memory buffer) { } } @@ -516,7 +517,7 @@ namespace System.Net.Sockets public static partial class SocketTaskExtensions { public static System.Threading.Tasks.Task AcceptAsync(this System.Net.Sockets.Socket socket) { throw null; } - public static System.Threading.Tasks.Task AcceptAsync(this System.Net.Sockets.Socket socket, System.Net.Sockets.Socket acceptSocket) { throw null; } + public static System.Threading.Tasks.Task AcceptAsync(this System.Net.Sockets.Socket socket, System.Net.Sockets.Socket? acceptSocket) { throw null; } public static System.Threading.Tasks.Task ConnectAsync(this System.Net.Sockets.Socket socket, System.Net.EndPoint remoteEP) { throw null; } public static System.Threading.Tasks.Task ConnectAsync(this System.Net.Sockets.Socket socket, System.Net.IPAddress address, int port) { throw null; } public static System.Threading.Tasks.Task ConnectAsync(this System.Net.Sockets.Socket socket, System.Net.IPAddress[] addresses, int port) { throw null; } @@ -551,15 +552,16 @@ namespace System.Net.Sockets public System.Net.Sockets.Socket Client { get { throw null; } set { } } public bool Connected { get { throw null; } } public bool ExclusiveAddressUse { get { throw null; } set { } } - public System.Net.Sockets.LingerOption LingerState { get { throw null; } set { } } + [System.Diagnostics.CodeAnalysis.DisallowNullAttribute] + public System.Net.Sockets.LingerOption? LingerState { get { throw null; } set { } } public bool NoDelay { get { throw null; } set { } } public int ReceiveBufferSize { get { throw null; } set { } } public int ReceiveTimeout { get { throw null; } set { } } public int SendBufferSize { get { throw null; } set { } } public int SendTimeout { get { throw null; } set { } } - public System.IAsyncResult BeginConnect(System.Net.IPAddress address, int port, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginConnect(System.Net.IPAddress[] addresses, int port, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginConnect(string host, int port, System.AsyncCallback requestCallback, object state) { throw null; } + public System.IAsyncResult BeginConnect(System.Net.IPAddress address, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginConnect(System.Net.IPAddress[] addresses, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginConnect(string host, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } public void Close() { } public void Connect(System.Net.IPAddress address, int port) { } public void Connect(System.Net.IPAddress[] ipAddresses, int port) { } @@ -589,8 +591,8 @@ namespace System.Net.Sockets public System.Net.Sockets.TcpClient AcceptTcpClient() { throw null; } public System.Threading.Tasks.Task AcceptTcpClientAsync() { throw null; } public void AllowNatTraversal(bool allowed) { } - public System.IAsyncResult BeginAcceptSocket(System.AsyncCallback callback, object state) { throw null; } - public System.IAsyncResult BeginAcceptTcpClient(System.AsyncCallback callback, object state) { throw null; } + public System.IAsyncResult BeginAcceptSocket(System.AsyncCallback? callback, object? state) { throw null; } + public System.IAsyncResult BeginAcceptTcpClient(System.AsyncCallback? callback, object? state) { throw null; } public static System.Net.Sockets.TcpListener Create(int port) { throw null; } public System.Net.Sockets.Socket EndAcceptSocket(System.IAsyncResult asyncResult) { throw null; } public System.Net.Sockets.TcpClient EndAcceptTcpClient(System.IAsyncResult asyncResult) { throw null; } @@ -626,10 +628,10 @@ namespace System.Net.Sockets public bool MulticastLoopback { get { throw null; } set { } } public short Ttl { get { throw null; } set { } } public void AllowNatTraversal(bool allowed) { } - public System.IAsyncResult BeginReceive(System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginSend(byte[] datagram, int bytes, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginSend(byte[] datagram, int bytes, System.Net.IPEndPoint endPoint, System.AsyncCallback requestCallback, object state) { throw null; } - public System.IAsyncResult BeginSend(byte[] datagram, int bytes, string hostname, int port, System.AsyncCallback requestCallback, object state) { throw null; } + public System.IAsyncResult BeginReceive(System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginSend(byte[] datagram, int bytes, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginSend(byte[] datagram, int bytes, System.Net.IPEndPoint? endPoint, System.AsyncCallback? requestCallback, object? state) { throw null; } + public System.IAsyncResult BeginSend(byte[] datagram, int bytes, string? hostname, int port, System.AsyncCallback? requestCallback, object? state) { throw null; } public void Close() { } public void Connect(System.Net.IPAddress addr, int port) { } public void Connect(System.Net.IPEndPoint endPoint) { } @@ -644,14 +646,14 @@ namespace System.Net.Sockets public void JoinMulticastGroup(System.Net.IPAddress multicastAddr) { } public void JoinMulticastGroup(System.Net.IPAddress multicastAddr, int timeToLive) { } public void JoinMulticastGroup(System.Net.IPAddress multicastAddr, System.Net.IPAddress localAddress) { } - public byte[] Receive(ref System.Net.IPEndPoint remoteEP) { throw null; } + public byte[] Receive([System.Diagnostics.CodeAnalysis.NotNullAttribute] ref System.Net.IPEndPoint? remoteEP) { throw null; } public System.Threading.Tasks.Task ReceiveAsync() { throw null; } public int Send(byte[] dgram, int bytes) { throw null; } - public int Send(byte[] dgram, int bytes, System.Net.IPEndPoint endPoint) { throw null; } - public int Send(byte[] dgram, int bytes, string hostname, int port) { throw null; } + public int Send(byte[] dgram, int bytes, System.Net.IPEndPoint? endPoint) { throw null; } + public int Send(byte[] dgram, int bytes, string? hostname, int port) { throw null; } public System.Threading.Tasks.Task SendAsync(byte[] datagram, int bytes) { throw null; } - public System.Threading.Tasks.Task SendAsync(byte[] datagram, int bytes, System.Net.IPEndPoint endPoint) { throw null; } - public System.Threading.Tasks.Task SendAsync(byte[] datagram, int bytes, string hostname, int port) { throw null; } + public System.Threading.Tasks.Task SendAsync(byte[] datagram, int bytes, System.Net.IPEndPoint? endPoint) { throw null; } + public System.Threading.Tasks.Task SendAsync(byte[] datagram, int bytes, string? hostname, int port) { throw null; } } public partial struct UdpReceiveResult : System.IEquatable { @@ -661,7 +663,7 @@ namespace System.Net.Sockets public byte[] Buffer { get { throw null; } } public System.Net.IPEndPoint RemoteEndPoint { get { throw null; } } public bool Equals(System.Net.Sockets.UdpReceiveResult other) { throw null; } - public override bool Equals(object obj) { throw null; } + public override bool Equals(object? obj) { throw null; } public override int GetHashCode() { throw null; } public static bool operator ==(System.Net.Sockets.UdpReceiveResult left, System.Net.Sockets.UdpReceiveResult right) { throw null; } public static bool operator !=(System.Net.Sockets.UdpReceiveResult left, System.Net.Sockets.UdpReceiveResult right) { throw null; } diff --git a/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.csproj b/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.csproj index b565b96..7229303 100644 --- a/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.csproj +++ b/src/libraries/System.Net.Sockets/ref/System.Net.Sockets.csproj @@ -1,6 +1,7 @@ $(NetCoreAppCurrent) + enable diff --git a/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj b/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj index f105c12e..f1941c2 100644 --- a/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj +++ b/src/libraries/System.Net.Sockets/src/System.Net.Sockets.csproj @@ -3,6 +3,7 @@ System.Net.Sockets true $(NetCoreAppCurrent)-Windows_NT;$(NetCoreAppCurrent)-Unix + enable