ReSharper 2018.3 Help

Code Inspection: Use preferred braces style (enforce braces in 'fixed' statement)

C# specification allows you to safely omit braces around single nested statements under some parent statements, e.g. if-else, foreach, etc. However, code style guidelines may differ in this regard. Some consider the braces here as a requirement, some consider them redundant. Whatever style you prefer, the important thing is to have consistent use of braces throughout your codebase. With ReSharper, you can define your preference for using braces after each type of code block and enforce this style.

ReSharper also provides multiple formatting rules for braces layout (whitespaces, tabs, and new lines). To see and configure these rules, open ReSharper options (ReSharper | Options), type braces in the search box, and check matched items on pages under Code Editing | C# | Formatting Style.

For more information about configuring and enforcing your preferences for optional braces, see Code Syntax Style: Braces for Single Nested Statements.

Last modified: 25 April 2019

See Also