Page MenuHomePhabricator

[clang-format] Special handling of spaces for C# code

Authored by jbcoe on Feb 25 2020, 9:45 AM.



Ensure that there are spaces around braces '{', '}'.

Ensure that there is a space before and after '=>'.

Ensure that 'async' and 'when' are considered as keywords when inserting spaces.

Diff Detail

Event Timeline

jbcoe created this revision.Feb 25 2020, 9:45 AM

As a general comment, we should consider which of these special cases can already be simulated by a combination of existing style options:
There are several Spaces* options there that can be used to independently control various spacing around parenthesis.

krasimir added inline comments.Feb 26 2020, 5:03 AM

Move this to the already existing } else if (Style.isCSharp()) { on line 2902 below.

jbcoe planned changes to this revision.Feb 26 2020, 5:07 AM
jbcoe updated this revision to Diff 246688.Feb 26 2020, 5:59 AM
jbcoe edited the summary of this revision. (Show Details)

Treat async and when as keywords.

Consolidate C# space insertion logic.

jbcoe updated this revision to Diff 246689.Feb 26 2020, 6:04 AM
jbcoe marked an inline comment as done.

remove commented out code

krasimir accepted this revision.Feb 26 2020, 6:44 AM
krasimir added inline comments.

If these values for these options make sense for Google style in general, consider updating the getGoogleStyle default style with a C#-specific section here:
I'd recommend doing this in a separate patch based on top of this one.

This revision is now accepted and ready to land.Feb 26 2020, 6:44 AM
Closed by commit rGe8c5fea243ce: [clang-format] Special handling of spaces for C# code (authored by Jonathan Coe <>). · Explain WhyFeb 26 2020, 7:35 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2020, 7:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript