diff options
author | Jonathan Coe <jbcoe@google.com> | 2020-06-09 14:35:02 +0100 |
---|---|---|
committer | Jonathan Coe <jbcoe@google.com> | 2020-06-09 14:50:34 +0100 |
commit | f22b0727fe767cc8da5e0c59f4e957a05472ffa7 (patch) | |
tree | 81b12870aca4f92a91b089c9c5da86bcf02303ba /clang/unittests/Format/FormatTestCSharp.cpp | |
parent | 70a21887f7bd0b38e7c0676d8b25cc8a9980e009 (diff) | |
download | llvm-f22b0727fe767cc8da5e0c59f4e957a05472ffa7.zip llvm-f22b0727fe767cc8da5e0c59f4e957a05472ffa7.tar.gz llvm-f22b0727fe767cc8da5e0c59f4e957a05472ffa7.tar.bz2 |
[clang-format] Microsoft style fixes for C# properties
Summary:
There should be no line break before the opening brace for Microsoft style property accessors when the accessor is a simple `{ get; set }`.
https://docs.microsoft.com/en-us/dotnet/csharp/properties
Reviewers: krasimir, MyDeveloperDay
Reviewed By: krasimir
Subscribers: cfe-commits
Tags: #clang-format, #clang
Differential Revision: https://reviews.llvm.org/D81467
Diffstat (limited to 'clang/unittests/Format/FormatTestCSharp.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTestCSharp.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/clang/unittests/Format/FormatTestCSharp.cpp b/clang/unittests/Format/FormatTestCSharp.cpp index bcf2c7a..a2c551e 100644 --- a/clang/unittests/Format/FormatTestCSharp.cpp +++ b/clang/unittests/Format/FormatTestCSharp.cpp @@ -245,13 +245,11 @@ TEST_F(FormatTestCSharp, Attributes) { "}"); verifyFormat("[TestMethod]\n" - "public string Host\n" - "{ set; get; }"); + "public string Host { set; get; }"); verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server " "listening on provided host\")]\n" - "public string Host\n" - "{ set; get; }"); + "public string Host { set; get; }"); verifyFormat( "[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n" @@ -711,13 +709,6 @@ class MyClass { Style.BraceWrapping.AfterFunction = true; verifyFormat(R"(// -public class SaleItem { - public decimal Price - { get; set; } -})", - Style); - - verifyFormat(R"(// class TimePeriod { public double Hours { @@ -730,6 +721,17 @@ class TimePeriod { } })", Style); + + // Microsoft style trivial property accessors have no line break before the + // opening brace. + auto MicrosoftStyle = getMicrosoftStyle(FormatStyle::LK_CSharp); + verifyFormat(R"(// +public class SaleItem +{ + public decimal Price { get; set; } +})", + MicrosoftStyle); + } TEST_F(FormatTestCSharp, CSharpSpaces) { |