Rock Your Code: Coding Standards for Microsoft .NET (8th Edition)

The 8th edition of the book, Rock Your Code: Coding Standards for Microsoft .NET, is available on Amazon. It consolidates Microsoft .NET coding standards and provides supplementary directives. Drawing insights from Microsoft’s code inspection tools, the book covers topics such as project setup, naming standards, class design, coding style, and more. The book's purpose is to facilitate superior code quality and swift integration of new team members. It's designed for use with Visual Studio 2022, C#, and .NET 8.

Collection Performance: Is LINQ Always the Most Performant Choice?

The article explores the performance implications of using LINQ for collection queries, finding that a conventional foreach() loop outperforms LINQ by 1.75 times in identifying items matching a given query. The conclusion suggests benchmarking to determine the optimal approach based on the nature of the query and elements being sought.

Code It Any Way You Want: Comparison of Passing Parameters in Methods

This article explores different methods of passing parameters into methods, including conventional, in operator, and ref readonly approaches, comparing their performance. Despite differences in syntax, benchmark results demonstrate similar performance among these methods.

String Performance: Appending a Character using the StringBuilder

The use of a single character with a StringBuilder from an ObjectPool can improve performance. Benchmark results show similar overall performance, but without an ObjectPool, using a character becomes more significant. It is recommended to use a character in such cases. EditorConfig setup can check for this issue using dotnet_diagnostic.CA1834.severity = warning.

General Performance Tips

These articles delves into indispensable tips that should consistently be integrated into your coding practices. Though these tips may seem small, their cumulative impact becomes pronounced, particularly when handling high message volumes. Embracing these fundamental practices can yield substantial benefits for overall performance.

Reference Type & Structure Performance: Hashing Classes, Records, and Structures

A SHA256 hash can be generated for a class, record, or structure using a specific code. Performance analysis shows that hashing a class is 1.032 times faster than a structure and 1.048 times more efficient than a record. The memory allocations for record, reference, and value types are also provided in bytes.