[clang-format] No space inserted between commas in C#

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits, MyDeveloperDay

Tags: #clang-format, #clang

Differential Revision: https://reviews.llvm.org/D76621
This commit is contained in:
Jonathan Coe 2020-03-23 17:17:27 +00:00
parent 63828a35da
commit 04336ada17
2 changed files with 7 additions and 0 deletions

View File

@ -3015,6 +3015,10 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (Right.is(TT_CSharpNullConditionalLSquare))
return false;
// No space between consecutive commas '[,,]'.
if (Left.is(tok::comma) && Right.is(tok::comma))
return false;
// Possible space inside `?[ 0 ]`.
if (Left.is(TT_CSharpNullConditionalLSquare))
return Style.SpacesInSquareBrackets;

View File

@ -640,9 +640,12 @@ TEST_F(FormatTestCSharp, CSharpSpaces) {
verifyFormat(R"(private float[,] Values;)", Style);
verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
Style.SpacesInSquareBrackets = true;
verifyFormat(R"(private float[ , ] Values;)", Style);
verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
}
TEST_F(FormatTestCSharp, CSharpNullableTypes) {