Skip to main content

RCS1051: Add/remove parentheses from condition in conditional operator

Properties

PropertyValue
Default Severitydisabled by default
Minimum language version-

Examples

Example #1

diagnostic.cs
x = y != null ? "true" : "false"
fix.cs
x = (y != null) ? "true" : "false"

Configuration

info

Option roslynator_conditional_operator_condition_parentheses_style is required to be set for this analyzer to work.

.editorconfig
# Add/remove parentheses to/from condition in conditional operator
roslynator_conditional_operator_condition_parentheses_style = include|omit|omit_when_condition_is_single_token

Applies to