From 304be842996652e6dc153bd95c0694ca5ff3bff1 Mon Sep 17 00:00:00 2001 From: Stephen Toub Date: Sun, 14 Apr 2019 22:50:55 -0400 Subject: [PATCH] Fix a few internal nullable annotations and comments (#23987) --- .../shared/System/Threading/ExecutionContext.cs | 8 ++++---- .../shared/System/Threading/TimerQueue.Portable.cs | 7 ++++--- .../InteropServices/WindowsRuntime/ConstantSplittableMap.cs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs b/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs index 358b24c..fb9790d 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/ExecutionContext.cs @@ -394,8 +394,8 @@ namespace System.Threading if (previousChangeNotifications != null && nextChangeNotifications != null) { // Notifications can't exist without values - Debug.Assert(previousExecutionCtx!.m_localValues != null); // TODO-NULLABLE: Compiler can't see that we're only here when this is non-null - Debug.Assert(nextExecutionCtx!.m_localValues != null); // TODO-NULLABLE: Compiler can't see that we're only here when this is non-null + Debug.Assert(previousExecutionCtx!.m_localValues != null); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/2388 + Debug.Assert(nextExecutionCtx!.m_localValues != null); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/2388 // Both contexts have change notifications, check previousExecutionCtx first foreach (IAsyncLocal local in previousChangeNotifications) { @@ -429,7 +429,7 @@ namespace System.Threading else if (previousChangeNotifications != null) { // Notifications can't exist without values - Debug.Assert(previousExecutionCtx!.m_localValues != null); // TODO-NULLABLE: Compiler can't see that we're only here when this is non-null + Debug.Assert(previousExecutionCtx!.m_localValues != null); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/2388 // No current values, so just check previous against null foreach (IAsyncLocal local in previousChangeNotifications) { @@ -443,7 +443,7 @@ namespace System.Threading else // Implied: nextChangeNotifications != null { // Notifications can't exist without values - Debug.Assert(nextExecutionCtx!.m_localValues != null); // TODO-NULLABLE: Compiler can't see that we're only here when this is non-null + Debug.Assert(nextExecutionCtx!.m_localValues != null); // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/2388 // No previous values, so just check current against null foreach (IAsyncLocal local in nextChangeNotifications!) // TODO-NULLABLE: https://github.com/dotnet/csharplang/issues/2388 { diff --git a/src/System.Private.CoreLib/shared/System/Threading/TimerQueue.Portable.cs b/src/System.Private.CoreLib/shared/System/Threading/TimerQueue.Portable.cs index 808ccc9..ed6e90f 100644 --- a/src/System.Private.CoreLib/shared/System/Threading/TimerQueue.Portable.cs +++ b/src/System.Private.CoreLib/shared/System/Threading/TimerQueue.Portable.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.Collections.Generic; using System.Diagnostics; @@ -56,7 +57,7 @@ namespace System.Threading { if (!_isScheduled) { - List timers = s_scheduledTimers; + List? timers = s_scheduledTimers; if (timers == null) { timers = InitializeScheduledTimerManager_Locked(); @@ -80,11 +81,11 @@ namespace System.Threading private static void TimerThread() { AutoResetEvent timerEvent = s_timerEvent; - List timersToFire = s_scheduledTimersToFire; + List timersToFire = s_scheduledTimersToFire!; List timers; lock (timerEvent) { - timers = s_scheduledTimers; + timers = s_scheduledTimers!; } int shortestWaitDurationMs = Timeout.Infinite; diff --git a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs index 8a3ed8a..03e0760 100644 --- a/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/WindowsRuntime/ConstantSplittableMap.cs @@ -206,7 +206,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime } } - object? IEnumerator.Current // TODO-NULLABLE: + object? IEnumerator.Current // TODO-NULLABLE: https://github.com/dotnet/roslyn/issues/23268 { get { -- 2.7.4