Skip to content

Commit

Permalink
Avoid/suppress Lock-to-object conversion warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jjonescz committed Feb 27, 2024
1 parent b63ab63 commit 374a93f
Show file tree
Hide file tree
Showing 3 changed files with 4 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 // 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;
}

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 @@ -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);
Expand Down

0 comments on commit 374a93f

Please sign in to comment.