// Try to parse the property accessor:
// https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
Tokens->setPosition(StoredPosition);
+ if (Style.BraceWrapping.AfterFunction == true)
+ addUnwrappedLine();
nextToken();
do {
switch (FormatTok->Tok.getKind()) {
"}");
verifyFormat("[TestMethod]\n"
- "public string Host { set; get; }");
+ "public string Host\n"
+ "{ set; get; }");
verifyFormat("[TestMethod(\"start\", HelpText = \"Starts the server "
"listening on provided host\")]\n"
- "public string Host { set; get; }");
+ "public string Host\n"
+ "{ set; get; }");
verifyFormat(
"[DllImport(\"Hello\", EntryPoint = \"hello_world\")]\n"
DefaultThirdArgument);
})",
Style);
+
+ // Brace wrapping and single-lining of accessor can be controlled by config.
+ Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+ Style.BraceWrapping.AfterFunction = true;
+
+ verifyFormat(R"(//
+public class SaleItem {
+ public decimal Price
+ { get; set; }
+})",
+ Style);
+
+ verifyFormat(R"(//
+class TimePeriod {
+ public double Hours
+ {
+ get {
+ return _seconds / 3600;
+ }
+ set {
+ _seconds = value * 3600;
+ }
+ }
+})",
+ Style);
}
TEST_F(FormatTestCSharp, CSharpSpaces) {