This is the list of guidelines that can be applied during code reviews for C# projects. The goal is to cover the patterns that are not necessarily covered by the official Microsoft style or Microsoft's Code Analysis, and to highlight the incorrect practices that are common in C# projects. The goal of those guidelines is to improve the expressiveness and the correctness of the code, through how it looks (formatting) and what it means (semantics).
Each guideline starts by a summary and an example of wrong piece of code and a correct one. It then follows with the explanation about what makes it wrong.
- FR0001 Do not use arbitrary indentation to “align” code.
- FR0002 Use consistent line breaks between arguments.
- FR0003 Use consistent line breaks in call chains.
- FR0004 Do not cut words for variable names in the middle.
- FR0005 Do not use arbitrary number of letters for variable names.
- SM0001 Do not repeat the same type twice during initialization.
- SM0002 Do not comment unnecessarily.
- SM0003 Do not use leading zeros in numbers (JavaScript octal notation).
- SM0004 Do not loop on collections with a
for. - SM0005 Make types of parameters as abstract as possible: example of incompatible types being requested from the caller by two consecutive methods.
- SM0006 Do not use arrays.
- SM0007 Methods should do one and one only thing (misconception that the reader should not have to jump through lots of methods: if he does, there is something wrong with abstraction, such as unhelpful methods, etc.)