Skip to content

Commit c280a46

Browse files
committed
Suppress System.Threading.Lock cast to object errors
1 parent 273bf5a commit c280a46

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/Condition.cs

+2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ private unsafe void RemoveWaiter(Waiter waiter)
8989

9090
public Condition(Lock @lock)
9191
{
92+
#pragma warning disable CS9216 // casting Lock to object
9293
ArgumentNullException.ThrowIfNull(@lock);
94+
#pragma warning restore CS9215
9395
_lock = @lock;
9496
}
9597

src/coreclr/nativeaot/System.Private.CoreLib/src/System/Threading/SyncTable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public static unsafe int AssignEntry(object obj, int* pHeader)
140140

141141
// Found a free entry to assign
142142
Debug.Assert(!entry.Owner.IsAllocated);
143-
Debug.Assert(entry.Lock == null);
143+
Debug.Assert(entry.Lock is null);
144144
Debug.Assert(entry.HashCode == 0);
145145

146146
// Set up the new entry. We should not fail after this point.

src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.Threading.NativeSinks.cs

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
using System.Runtime.CompilerServices;
66
using System.Threading;
77

8+
#pragma warning disable CS9216 // System.Threading.Lock cast to object for object identity
9+
810
namespace System.Diagnostics.Tracing
911
{
1012
// This is part of the NativeRuntimeEventsource, which is the managed version of the Microsoft-Windows-DotNETRuntime provider.

src/libraries/System.Private.CoreLib/src/System/Threading/Lock.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ internal Scope(Lock lockObj, ThreadId currentThreadId)
130130
public void Dispose()
131131
{
132132
Lock? lockObj = _lockObj;
133-
if (lockObj != null)
133+
if (lockObj is not null)
134134
{
135135
_lockObj = null;
136136
lockObj.Exit(_currentThreadId);

0 commit comments

Comments
 (0)