Best newsletters and posts about Microsoft NET Code Analysis tag


Messages

5/31/2023 9:15:58 PM

[New post] Microsoft .NET Code Analysis: Remove Unnecessary Using Directives

dotNetDave posted: " I always remove unnecessary using directives for a few reasons that I discuss in detail in my coding standards book and conference session. First, let me show the issue: using
5/31/2023 9:25:58 PM

[New post] Microsoft .NET Code Analysis: aDD bRACES IN c#

dotNetDave posted: " Not adding braces {} to if statements can cause issues and readability issues. This code causes a violation: if (somelist[i] != other.somelist[i]) return false; This is how
5/31/2023 9:05:01 PM

[New post] Microsoft .NET Code Analysis: Remove Unnecessary Casts

dotNetDave posted: " Type casting converts one type to another. Unnecessary type casting not only makes the code less “clean”, but it also can be a performance issue. This code shows the issue:
5/31/2023 9:45:19 PM

[New post] Microsoft .NET Code Analysis: Inline Variable Declaration

dotNetDave posted: " Starting with .NET 7, when calling a method with an out parameter, it's advisable to inline the variable declaration. Here is an example of the issue: double number1;if(
5/31/2023 10:25:16 PM

[New post] Microsoft .NET Code Analysis: The Importance of the readonly Modifier

dotNetDave posted: " The readonly modifier is used to designate fields or variables that can only be assigned once, typically during object creation or in the constructor. It is commonly employed
5/31/2023 10:17:12 PM

[New post] Microsoft .NET Code Analysis: Always Use Accessibility Modifiers

dotNetDave posted: " Accessibility modifiers are used to control the visibility of accessibility of types and members and are critical for proper Object-Oriented Programming. Here is why you need
5/31/2023 10:17:04 PM

[New post] Microsoft .NET Code Analysis: Remove Unread Private Members

dotNetDave posted: " As code is removed or changed in a class, often that might create unused private members such as variables, methods, properties, etc. It's important to remove them to
5/31/2023 10:54:59 PM

[New post] Microsoft .NET Code Analysis: Use Compound Assignments

dotNetDave posted: " Compound assignments have been available since .NET was released and is the preferred way to modify numbers and strings. Here is an example of the issue: var peopleCount = 0;
5/31/2023 11:04:27 PM

[New post] Microsoft .NET Code Analysis: Use the Index Operator

dotNetDave posted: " C# 8 introduced the index-from-end operator when accessing items in a collection. Here is an example of this prior to C# 8: return results[results.Count - 1]; In this case,
6/1/2023 8:26:31 PM

[New post] Microsoft .NET Code Analysis: Remove Unnecessary Expression Values

dotNetDave posted: " When coding, it is crucial not to overlook or discard the value returned by a method. Neglecting the return value is not just a matter of style; it has implications that go
6/1/2023 8:44:34 PM

[New post] Microsoft .NET Code Analysis: Remove Unnecessary Value Assignments

dotNetDave posted: " For performance, it's very important to remove unnecessary value assignments that need to be cleaned up. Here is an example of the issue: List<People> users = null;
6/1/2023 9:14:31 PM

[New post] Microsoft .NET Code Analysis: Remove Unused Parameters

dotNetDave posted: " Unused parameters in methods can lead to numerous issues and should be consistently removed. During my review of the code base for this blog post, I encountered a substantial
6/2/2023 8:04:27 AM

[New post] Microsoft .NET Code Analysis: Proper Using Directive Placement

dotNetDave posted: " In .NET, there are multiple places you can place using directives in a code file. The coding standard is to place them outside of the namespace. Here are the reasons why: Code
6/3/2023 8:14:33 AM

[New post] Microsoft .NET Code Analysis: Use the Switch Expressions Instead of Statements

dotNetDave posted: " Switch expressions were introduced in .NET Core 3 and is now the recommended approach for implementing switch statements due to several advantages. Consider the following
6/4/2023 8:04:26 AM

[New post] Microsoft .NET Code Analysis: Use Pattern Matching

dotNetDave posted: " Pattern matching was introduced in the C# programming language with the release of C# 7 and has since become the preferred approach for checking the shape or structure of data
6/5/2023 8:14:30 AM

[New post] Microsoft .NET Code Analysis: Enums Should Always Have a Zero Value

dotNetDave posted: " When reviewing code, one common issue I often encounter is the absence of a default or "not set" value for Enums. This is a crucial consideration in most cases as it
6/6/2023 8:14:31 AM

[New post] Microsoft .NET Code Analysis: The Rijndael and Rijndaelmanaged Types Are Superseded

dotNetDave posted: " Since September 2021, the Rijndael and RijndaelManaged types have been superseded by the AesManaged type. Although Rijndael is still supported in .NET, it is generally not
6/27/2023 4:04:44 PM

[New post] Microsoft .NET Code Analysis: Always Add Braces in C#

dotNetDave posted: " Not adding braces {} to if statements can lead to issues and affect code readability. The following code demonstrates a violation of this practice: if (somelist[i] != other.