Lock keyword gets an upgrade in .NET9

#531 – November 10, 2024

How traditional locking works through ThinLock and SyncBlock

Lock keyword gets an upgrade in .NET9
9 minutes by Marek Sirkovský

Marek discusses the evolution of locking mechanisms in C#, focusing on the transition from using object type for locking to the new System.Threading.Lock type introduced in .NET 9. He explains how traditional locking works through ThinLock and SyncBlock mechanisms, and how the new Lock type offers a more semantically clear and potentially more efficient approach to thread synchronization.

New Report: State of Designer-Developer Collaboration 2024
sponsored by Progress

Whether you’re on the development or design end of creating web applications, it’s easy to lose track of the world beyond your daily work. This brand-new report will give you some interesting insights and in-depth analysis on the relationship between designers and developers, including excellent ideas for making it more efficient and satisfying. Check it out.

What is Mutation Testing and Why Should You Use It?
6 minutes by Dawid Sibiński

What is mutation testing? Why should you use it? How to generate unit tests for free with mutation testing? Mutation testing works by intentionally introducing small changes (mutations) to the source code and checking if the existing tests can detect these changes. If tests fail after a mutation, the mutant is "killed," indicating good test coverage; if tests pass, the mutant "survives," revealing potential gaps in testing.

Exploring Early Return in .NET Methods
4 minutes by David McCarter

Dave compares two method return patterns: traditional single-exit point and early returns, providing code examples and benchmark results. While early returns showed a slight performance improvement of 0.0196 ns, Dave suggests their main benefits are improved code readability, simplified complexity, and better adherence to the Single Responsibility Principle.

Working With DTO Auto Translators
7 minutes by Peter Ritchie

The article discusses the Mapperly package, a .NET Source Generator for handling Data Transfer Objects (DTOs) in modern software applications. Unlike other mapping tools like AutoMapper and Mapster, Mapperly generates translation code at compile-time, making it more efficient and straightforward to use.

C# Records
4 minutes by Paul Michaels

Records in .NET 5 (C# 9) were introduced as a specialized type of class optimized for storing data, offering several advantages over traditional classes. They are immutable by default, provide automatic implementation of ToString() for better object representation, and implement value-based equality comparison rather than reference-based.

newsletters