Code Quality Rules
Diagnostics enforced at Warning severity. Code triggering these will be flagged in review.
Enforced Diagnostics
| Rule ID | What It Catches | Severity |
|---|---|---|
| IDE0005 | Unnecessary using directives |
Warning |
| IDE0011 | Missing braces on multiline blocks | Warning |
| IDE0035 | Unreachable code | Warning |
| IDE0036 | Incorrect modifier ordering | Warning |
| IDE0040 | Missing accessibility modifiers | Warning |
| IDE0043 | Invalid format string placeholder | Warning |
| IDE0044 | Field should be readonly |
Warning |
| IDE0051 | Unused private members | Warning |
| IDE0052 | Unread private members | Warning |
| IDE0059 | Unnecessary value assignment | Warning |
| IDE0060 | Unused parameters | Warning |
| CA1012 | Abstract type has public constructor | Warning |
| CA1822 | Member can be static |
Warning |
Whitespace Diagnostics
| Rule ID | What It Catches | Severity |
|---|---|---|
| IDE2000 | Multiple consecutive blank lines | Warning |
| IDE2001 | Embedded statement on same line as block | Warning |
| IDE2002 | Blank line between consecutive braces | Warning |
| IDE2003 | Statement immediately after block close | Warning |
| IDE2004 | Blank line after colon in ctor initializer | Warning |
Modifier Ordering
Always use this order:
public / private / protected / internal
static
extern
new
virtual / abstract / override / sealed
readonly
unsafe
volatile
async
// GOOD
public static readonly int Value;
private protected override async Task<int> ComputeAsync();
// BAD
static public readonly int Value;
async private protected override Task<int> ComputeAsync();
Tools
- Roslyn Analyzers — IDE0xxx rules
- .NET Code Analysis — CAxxx rules
- EditorConfig — enforce formatting across editors