You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CSharpier is an opinionated formatter and adding an option goes against that.
I would consider always forcing braces, but I don't know how split developers are in the always braces vs no braces. There are also other tools to force braces, they just don't run on save.
belav
changed the title
Define strategies for curly brackets on conditions and loops
Consider - forcing braces on loops and if statements.
Aug 11, 2023
I feel like this is unlikely to get strong consensus in community.
Personally, I like no-brace style for short single-line statements like if (!alive) return;.
I know other people who swear by always-use-braces.
I think it's probably simpler for CSharpier to stick to its "no-syntax change, whitespace formatting-only" general policy on this one.
Braces can be enforced by linters (even C# by itself can be configured through .editorconfig to error on if without braces).
(BTW in the same category: dropping brackets around single-argument, type-less lambdas? Prettier has an option to change (x) => true into x => true. I like this but I feel my comment applies just the same for this one.)
Hello,
It would be nice if we could enforce the curly brackets for conditions and loops. Probably, a strategy for that would be better, something like:
What do you think?
The text was updated successfully, but these errors were encountered: