Fix nullability warnings in System.Diagnostics.Process (#32211)
authorStephen Toub <stoub@microsoft.com>
Thu, 13 Feb 2020 06:01:42 +0000 (22:01 -0800)
committerGitHub <noreply@github.com>
Thu, 13 Feb 2020 06:01:42 +0000 (22:01 -0800)
src/libraries/Common/src/System/Threading/Tasks/TaskCompletionSourceWithCancellation.cs
src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs

index a5d667e..c19e22f 100644 (file)
@@ -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
 namespace System.Threading.Tasks
 {
     /// <summary>
@@ -25,7 +26,7 @@ namespace System.Threading.Tasks
         public async ValueTask<T> WaitWithCancellationAsync(CancellationToken cancellationToken)
         {
             _cancellationToken = cancellationToken;
-            using (cancellationToken.UnsafeRegister(s => ((TaskCompletionSourceWithCancellation<T>)s).OnCancellation(), this))
+            using (cancellationToken.UnsafeRegister(s => ((TaskCompletionSourceWithCancellation<T>)s!).OnCancellation(), this))
             {
                 return await Task.ConfigureAwait(false);
             }
index 074f4ad..7d5b28f 100644 (file)
@@ -1426,9 +1426,9 @@ namespace System.Diagnostics
                 throw;
             }
 
-            var tcs = new TaskCompletionSourceWithCancellation<object>();
+            var tcs = new TaskCompletionSourceWithCancellation<bool>();
 
-            EventHandler handler = (s, e) => tcs.TrySetResult(null);
+            EventHandler handler = (s, e) => tcs.TrySetResult(true);
             Exited += handler;
 
             try