diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs index 70843a3b940fc..ceb60edb12e3f 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs @@ -89,7 +89,9 @@ private unsafe void RemoveWaiter(Waiter waiter) public Condition(Lock @lock) { +#pragma warning disable CS9216 // A value of type 'System.Threading.Lock' converted to a different type will use likely unintended monitor-based locking in 'lock' statement. ArgumentNullException.ThrowIfNull(@lock); +#pragma warning restore CS9216 _lock = @lock; } diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/SyncTable.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/SyncTable.cs index 02d7b4167ca6b..bdbf6ed752e6c 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/SyncTable.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/SyncTable.cs @@ -140,7 +140,7 @@ public static unsafe int AssignEntry(object obj, int* pHeader) // Found a free entry to assign Debug.Assert(!entry.Owner.IsAllocated); - Debug.Assert(entry.Lock == null); + Debug.Assert(entry.Lock is null); Debug.Assert(entry.HashCode == 0); // Set up the new entry. We should not fail after this point. diff --git a/src/libraries/System.Private.CoreLib/src/System/Threading/Lock.cs b/src/libraries/System.Private.CoreLib/src/System/Threading/Lock.cs index 056ff96d41b1e..4828a6dd2b0e5 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Threading/Lock.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Threading/Lock.cs @@ -120,7 +120,7 @@ internal Scope(Lock lockObj, ThreadId currentThreadId) public void Dispose() { Lock? lockObj = _lockObj; - if (lockObj != null) + if (lockObj is not null) { _lockObj = null; lockObj.Exit(_currentThreadId);