diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs index 13bb163974c96..de2281e32b59a 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.cs @@ -88,7 +88,7 @@ public partial struct ManualResetValueTaskSourceCore public short Version { get { throw null; } } public TResult GetResult(short token) { throw null; } public System.Threading.Tasks.Sources.ValueTaskSourceStatus GetStatus(short token) { throw null; } - public void OnCompleted(System.Action continuation, object state, short token, System.Threading.Tasks.Sources.ValueTaskSourceOnCompletedFlags flags) { } + public void OnCompleted(System.Action continuation, object? state, short token, System.Threading.Tasks.Sources.ValueTaskSourceOnCompletedFlags flags) { } public void Reset() { } public void SetException(System.Exception error) { } public void SetResult(TResult result) { } diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.csproj b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.csproj index 3e1cfcc8794ef..b7bbceaa14bbb 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.csproj +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/ref/Microsoft.Bcl.AsyncInterfaces.csproj @@ -1,7 +1,6 @@ netstandard2.0;$(NetFrameworkMinimum);netstandard2.1 - disable diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/Microsoft.Bcl.AsyncInterfaces.csproj b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/Microsoft.Bcl.AsyncInterfaces.csproj index 92348fbe61e3d..313bc2ab4868d 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/Microsoft.Bcl.AsyncInterfaces.csproj +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/Microsoft.Bcl.AsyncInterfaces.csproj @@ -1,7 +1,6 @@ netstandard2.0;$(NetFrameworkMinimum);netstandard2.1 - disable true Provides the IAsyncEnumerable<T> and IAsyncDisposable interfaces and helper types for .NET Standard 2.0. This package is not required starting with .NET Standard 2.1 and .NET Core 3.0. diff --git a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs index 87dd49c49fb71..8bcc9cb17b79b 100644 --- a/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs +++ b/src/libraries/Microsoft.Bcl.AsyncInterfaces/src/System/Threading/Tasks/Sources/ManualResetValueTaskSourceCore.cs @@ -26,22 +26,22 @@ public struct ManualResetValueTaskSourceCore /// or if the operation completed before a callback was supplied, /// or null if a callback hasn't yet been provided and the operation hasn't yet completed. /// - private Action _continuation; + private Action? _continuation; /// State to pass to . - private object _continuationState; + private object? _continuationState; /// to flow to the callback, or null if no flowing is required. - private ExecutionContext _executionContext; + private ExecutionContext? _executionContext; /// /// A "captured" or with which to invoke the callback, /// or null if no special context is required. /// - private object _capturedContext; + private object? _capturedContext; /// Whether the current operation has completed. private bool _completed; /// The result with which the operation succeeded, or the default value if it hasn't yet completed or failed. - private TResult _result; + private TResult? _result; /// The exception with which the operation failed, or null if it hasn't yet completed or completed successfully. - private ExceptionDispatchInfo _error; + private ExceptionDispatchInfo? _error; /// The current version of this value, used to help prevent misuse. private short _version; @@ -105,7 +105,7 @@ public TResult GetResult(short token) } _error?.Throw(); - return _result; + return _result!; } /// Schedules the continuation action for this operation. @@ -113,7 +113,7 @@ public TResult GetResult(short token) /// The state object to pass to when it's invoked. /// Opaque value that was provided to the 's constructor. /// The flags describing the behavior of the continuation. - public void OnCompleted(Action continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags) + public void OnCompleted(Action continuation, object? state, short token, ValueTaskSourceOnCompletedFlags flags) { if (continuation is null) { @@ -128,7 +128,7 @@ public void OnCompleted(Action continuation, object state, short token, if ((flags & ValueTaskSourceOnCompletedFlags.UseSchedulingContext) != 0) { - SynchronizationContext sc = SynchronizationContext.Current; + SynchronizationContext? sc = SynchronizationContext.Current; if (sc != null && sc.GetType() != typeof(SynchronizationContext)) { _capturedContext = sc; @@ -151,7 +151,7 @@ public void OnCompleted(Action continuation, object state, short token, // To minimize the chances of that, we check preemptively whether _continuation // is already set to something other than the completion sentinel. - object oldContinuation = _continuation; + object? oldContinuation = _continuation; if (oldContinuation == null) { _continuationState = state; @@ -175,7 +175,7 @@ public void OnCompleted(Action continuation, object state, short token, case SynchronizationContext sc: sc.Post(s => { - var tuple = (Tuple, object>)s; + var tuple = (Tuple, object?>)s!; tuple.Item1(tuple.Item2); }, Tuple.Create(continuation, state)); break; @@ -212,7 +212,7 @@ private void SignalCompletion() { ExecutionContext.Run( _executionContext, - s => ((ManualResetValueTaskSourceCore)s).InvokeContinuation(), + s => ((ManualResetValueTaskSourceCore)s!).InvokeContinuation(), this); } else @@ -247,7 +247,7 @@ private void InvokeContinuation() case SynchronizationContext sc: sc.Post(s => { - var state = (Tuple, object>)s; + var state = (Tuple, object?>)s!; state.Item1(state.Item2); }, Tuple.Create(_continuation, _continuationState)); break; @@ -261,8 +261,8 @@ private void InvokeContinuation() internal static class ManualResetValueTaskSourceCoreShared // separated out of generic to avoid unnecessary duplication { - internal static readonly Action s_sentinel = CompletionSentinel; - private static void CompletionSentinel(object _) // named method to aid debugging + internal static readonly Action s_sentinel = CompletionSentinel; + private static void CompletionSentinel(object? _) // named method to aid debugging { Debug.Fail("The sentinel delegate should never be invoked."); throw new InvalidOperationException();