The author details extensive performance benchmarking of .NET 8, showcasing its notable improvements but also highlighting areas of performance regression compared to .NET 6. The areas of regression include slows in object creation, disposing, checking for null, array creation, LINQ methods, string handling, string compression, finding strings, encoding and decoding, and certain LINQ APIs and Lambda methods. He encourages developers to benchmark their code before transitioning to .NET 8.
Category: C#
Microsoft .NET Code Analysis: Utilize Pattern Matching to Eliminate the Need for an ‘is’ Check
The author identifies inefficiencies in type conversions within a code sample from the Entity Framework codebase, suggesting improvements through pattern matching. They note 22 instances requiring fixes and recommend using their updated EditorConfig file for similar analyses. Feedback on their open-source project, Spargine, is welcomed.
Microsoft .NET Code Analysis: Use nameof() To Retrieve the Parameter Name
The article discusses the importance of using `nameof()` in code to retrieve parameter names, highlighting how it helps prevent issues when parameter names change during refactoring by automatically updating them in exception handling. Additionally, it mentions that `nameof()` provides performance benefits by generating names during the build process rather than at runtime.
Microsoft .NET Code Analysis: Choosing Between String.Contains() and String.IndexOf()
In this article, we explore Microsoft's recommendation to utilize the String.Contains() method instead of String.IndexOf() for improved code readability. We provide code examples to illustrate this suggestion and discuss its relevance in the context of common coding practices, referencing its application in Entity Framework source code and adherence to coding standards like CA2249.
Microsoft .NET Code Analysis: Remove Unnecessary Lambda Expressions
Microsoft recommends removing redundant Lambda expressions, which can be identified based on specific conditions such as the presence of method invocations, matching parameters, and other criteria. The article provides an example of code improvement by eliminating unnecessary Lambda expressions in Entity Framework source code, addressing violations like IDE0200.
Microsoft .NET Code Analysis: Improving Code Quality with Exception Throw Helpers
Improve your C# code's clarity and adherence to coding standards by using Microsoft's recommended throw helpers for exception handling. This article demonstrates how to apply these helpers for common exceptions, like ArgumentNullException and ArgumentException, with real-world examples from the Entity Framework source code.
Microsoft .NET Code Analysis: Enhance Your Code Performance with Concrete Types
Discover the performance benefits of using concrete types over abstract or interface types in your code. Learn from a real-world Entity Framework example and gain practical insights into improving code quality and efficiency through this optimization technique.
Nullable Type Performance: Retrieving a Nullable Value
The article discusses performance for the three methods for retrieving nullable values in C#, including using the nullable modifier '?' with HasValue and Value properties, the null coalescing operator ??, and the GetValueOrDefault() method.
Microsoft .NET Code Analysis: Optimizing String Methods for Performance – Leveraging Character Over String for Enhanced Efficiency
The article suggests using the string.Method(char) approach instead of string.Method(string) for strings containing a single character to improve performance. It highlights an example where this optimization can be applied in the Entity Framework source code and mentions that this deviation from the recommended guideline occurred 34 times in the codebase. The article also references violation codes CA1865 – CA1867 and mentions their severity settings in the .editorConfig file. Update March, 2024.
dotNetDave Rocks the Build Stuff Conference 2023
I'm thrilled to announce that, for the very first time, the For Those About To Code: World Wide Tour will be making a stop at the 2023 Build Stuff event in Vilnius, Lithuania from November 15th to 17th! This marks my first visit to Lithuania, and I'm eagerly anticipating an amazing time with fellow tech enthusiasts.

You must be logged in to post a comment.