Skip to content

Commit

Permalink
Suppress System.Threading.Lock cast to object errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Mar 13, 2024
1 parent 1d80182 commit 084c470
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ private unsafe void RemoveWaiter(Waiter waiter)

public Condition(Lock @lock)
{
#pragma warning disable CS9216 // casting Lock to object
ArgumentNullException.ThrowIfNull(@lock);
#pragma warning restore CS9215
_lock = @lock;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Runtime.CompilerServices;
using System.Threading;

#pragma warning disable CS9216 // System.Threading.Lock cast to object for object identity

namespace System.Diagnostics.Tracing
{
// This is part of the NativeRuntimeEventsource, which is the managed version of the Microsoft-Windows-DotNETRuntime provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using System.Runtime.CompilerServices;
using System.Threading;

#pragma warning disable CS9216 // System.Threading.Lock cast to object for object identity

namespace System.Diagnostics.Tracing
{
// This is part of the NativeRuntimeEventsource, which is the managed version of the Microsoft-Windows-DotNETRuntime provider.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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);
Expand Down

0 comments on commit 084c470

Please sign in to comment.