diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -466,7 +466,7 @@ (NextTok->is(tok::semi) && (!ExpectClassBody || LBraceStack.size() != 1)) || (NextTok->isBinaryOperator() && !NextIsObjCMethod); - if (NextTok->is(tok::l_square)) { + if (!Style.isCSharp() && NextTok->is(tok::l_square)) { // We can have an array subscript after a braced init // list, but C++11 attributes are expected after blocks. NextTok = Tokens->getNextToken(); diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -316,6 +316,27 @@ " }\n" "}\n", Style); + + verifyFormat("public A : Base\n" + "{\n" + "}\n" + "[Test]\n" + "public Foo()\n" + "{\n" + "}\n", + Style); + + verifyFormat("namespace\n" + "{\n" + "public A : Base\n" + "{\n" + "}\n" + "[Test]\n" + "public Foo()\n" + "{\n" + "}\n" + "}\n", + Style); } TEST_F(FormatTestCSharp, CSharpSpaceBefore) {