For twenty years, lock (x) meant exactly one thing in IL: Monitor.Enter , a try , and a guarded Monitor.Exit . You could read the pattern in your sleep. C# 13 quietly broke that reflex. Lock over the new System.Threading.Lock type no longer calls Monitor at all — it calls EnterScope() and disposes a ref struct in a finally . The source still reads lock (x) . The IL is a different shape entirely, and a decompiler that has not learned the new shape will either miss the lock or print a using that was never there.
The real question
The syntax did not change. Both of these are legal, and both read lock (_gate) { ... } :
private readonly object _gate = new ( ) ; // classic private readonly System . Threading . Lock _lock = new ( ) ; // C# 13
Enter fullscreen mode
Exit fullscreen mode
The compiler looks at the static type of the operand. If it is System.Threading.Lock , it emits the new scope-based lowering.…