All rules
IDE0029Null-checking preferences MS default: Suggestion
Use coalesce expression
Prefer the null-coalescing operator `??` over equivalent conditionals.
Microsoft docsDescription
Suggests replacing x != null ? x : y style conditionals with the ?? operator.
Why it matters
The coalesce operator is shorter and removes a branch that can hide subtle bugs.
Examples
Avoid
var name = input != null ? input : "anonymous"; Prefer
var name = input ?? "anonymous";Configurable options
Vote for the value each option should take in the generated .editorconfig.
dotnet_style_coalesce_expression default:
trueYour vote
Group results
0 yes 0 no
ConsensusNone (disabled)
Severity preference (yes voters)
Suggestion0
Warning0
Error0