Suppose I have the following code:
public class SomeClass()
{
private readonly object _lock = new object();
public void SomeMethodA()
{
lock
I have no experience whatsoever with .NET programming, but in my own code (Delphi) I have once implemented such assertions by having custom Acquire() and Release() methods in a critical section class, with a private member variable for the id of the thread having acquired the cs. After EnterCriticalSection() the return value of GetCurrentThreadID was written, and before LeaveCriticalSection() the field value was reset.
But I don't know whether .NET allows a similar thing, or whether you could implement this in your program...