Lines Matching defs:Style

25                             const FormatStyle &Style) {
29 tooling::Replacements Replaces = reformat(Style, Code, Ranges);
38 const FormatStyle &Style = getMicrosoftStyle(FormatStyle::LK_CSharp)) {
39 return format(Code, 0, Code.size(), Style);
43 FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
44 Style.ColumnLimit = ColumnLimit;
45 return Style;
72 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
73 Style.BreakBeforeBraces = FormatStyle::BS_Attach;
75 verifyFormat("public class SomeEmptyClass {}", Style);
80 Style);
84 Style);
88 Style);
92 Style);
129 auto Style = getDefaultStyle();
130 Style.ColumnLimit = 40;
131 Style.BreakStringLiterals = true;
135 Style);
141 auto Style = getDefaultStyle();
142 Style.BreakStringLiterals = true;
146 Style);
148 Style.ColumnLimit = 40;
155 Style);
163 Style);
165 Style.BreakBeforeBinaryOperators = FormatStyle::BOS_NonAssignment;
172 Style);
173 Style.AlignOperands = FormatStyle::OAS_AlignAfterOperator;
180 Style);
186 Style);
226 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
228 verifyFormat("var y = A < B ? -1 : 1;", Style);
232 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
233 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
241 Style);
243 verifyFormat("switch (args?.Length) {}", Style);
250 Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
252 verifyFormat("switch(args?.Length) {}", Style);
396 // Modify Style to enforce a column limit.
397 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
398 Style.ColumnLimit = 10;
401 Style);
405 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
406 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
411 Style);
415 Style);
417 Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
422 Style);
426 Style);
428 Style.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
433 Style);
437 Style);
439 Style.SpaceBeforeParens = FormatStyle::SBPO_NonEmptyParentheses;
444 Style);
448 Style);
474 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
475 Style.SpaceBeforeAssignmentOperators = true;
477 verifyFormat(R"(test ??= ABC;)", Style);
478 verifyFormat(R"(test ??= true;)", Style);
480 Style.SpaceBeforeAssignmentOperators = false;
482 verifyFormat(R"(test??= ABC;)", Style);
483 verifyFormat(R"(test??= true;)", Style);
487 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
489 verifyFormat("var test = null!;", Style);
490 verifyFormat("string test = someFunctionCall()! + \"ABC\"!", Style);
491 verifyFormat("int test = (1! + 2 + bar! + foo())!", Style);
492 verifyFormat(R"(test ??= !foo!;)", Style);
493 verifyFormat("test = !bar! ?? !foo!;", Style);
496 Style);
499 Style.ColumnLimit = 14;
503 Style);
507 FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
508 Style.BreakAfterReturnType = FormatStyle::RTBS_None;
514 Style);
521 Style);
528 Style);
534 Style);
540 Style);
546 Style);
555 Style);
564 Style);
576 Style);
580 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
581 Style.SpaceBeforeParens = FormatStyle::SBPO_Always;
583 verifyFormat("List<string> list;", Style);
584 verifyFormat("Dictionary<string, string> dict;", Style);
588 Style);
591 Style);
592 verifyFormat("switch (x) {}", Style);
595 Style);
597 Style.SpaceBeforeParens = FormatStyle::SBPO_Never;
599 verifyFormat("List<string> list;", Style);
600 verifyFormat("Dictionary<string, string> dict;", Style);
604 Style);
607 Style);
608 verifyFormat("switch(x) {}", Style);
611 Style);
615 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
617 verifyFormat("(int)x / y;", Style);
619 Style.SpaceAfterCStyleCast = true;
620 verifyFormat("(int) x / y;", Style);
624 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
626 verifyFormat(R"(string str = @"""";)", Style);
627 verifyFormat(R"(string str = @"""Hello world""";)", Style);
628 verifyFormat(R"(string str = $@"""Hello {friend}""";)", Style);
629 verifyFormat(R"(return $@"Foo ""/foo?f={Request.Query["f"]}""";)", Style);
630 verifyFormat(R"(return @$"Foo ""/foo?f={Request.Query["f"]}""";)", Style);
631 verifyFormat(R"(return @$"path\to\{specifiedFile}")", Style);
635 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
637 verifyFormat(R"(string str1 = $"{null ?? "null"}";)", Style);
638 verifyFormat(R"(string str2 = $"{{{braceCount} braces";)", Style);
639 verifyFormat(R"(string str3 = $"{braceCount}}} braces";)", Style);
643 // Use MS style as Google Style inserts a line break before multiline strings.
648 FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
655 EXPECT_EQ(Code, format(Code, Style));
665 EXPECT_EQ(Code, format(Code, Style));
671 EXPECT_EQ(Code, format(Code, Style));
675 FormatStyle Style = getLLVMStyle(FormatStyle::LK_CSharp);
680 Style);
689 Style);
705 // Microsoft Style:
958 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
974 Style);
980 Style);
988 Style);
997 Style);
1001 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1008 Style);
1012 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1016 Style);
1022 Style);
1024 verifyFormat(R"(foreach (var tickCount in task.Begin(seed: 0)) {)", Style);
1028 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1030 verifyFormat("int Value { get }", Style);
1031 verifyFormat("int Value { get; }", Style);
1032 verifyFormat("int Value { internal get; }", Style);
1033 verifyFormat("int Value { get; } = 0", Style);
1034 verifyFormat("int Value { set }", Style);
1035 verifyFormat("int Value { set; }", Style);
1036 verifyFormat("int Value { init; }", Style);
1037 verifyFormat("int Value { internal set; }", Style);
1038 verifyFormat("int Value { set; } = 0", Style);
1039 verifyFormat("int Value { get; set }", Style);
1040 verifyFormat("int Value { get; init; }", Style);
1041 verifyFormat("int Value { set; get }", Style);
1042 verifyFormat("int Value { get; private set; }", Style);
1043 verifyFormat("int Value { get; set; }", Style);
1044 verifyFormat("int Value { get; set; } = 0", Style);
1045 verifyFormat("int Value { internal get; internal set; }", Style);
1053 Style);
1059 Style);
1065 Style);
1077 Style);
1091 Style);
1098 Style);
1101 Style.ColumnLimit = 100;
1111 Style);
1122 Style);
1125 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Never;
1126 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
1127 Style.BraceWrapping.AfterFunction = true;
1141 Style);
1166 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1169 "T[] InitializeArray<T>(int length, T initialValue = default) {}", Style);
1170 verifyFormat("System.Numerics.Complex fillValue = default;", Style);
1171 verifyFormat("int Value { get } = default;", Style);
1172 verifyFormat("int Value { get } = default!;", Style);
1177 Style);
1182 Style);
1186 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1187 Style.SpaceBeforeSquareBrackets = false;
1188 Style.SpacesInSquareBrackets = false;
1189 Style.SpaceBeforeCpp11BracedList = true;
1190 Style.Cpp11BracedListStyle = false;
1191 Style.SpacesInContainerLiterals = false;
1192 Style.SpaceAfterCStyleCast = false;
1194 verifyFormat(R"(new Car { "Door", 0.1 })", Style);
1195 verifyFormat(R"(new Car { 0.1, "Door" })", Style);
1196 verifyFormat(R"(new string[] { "A" })", Style);
1197 verifyFormat(R"(new string[] {})", Style);
1198 verifyFormat(R"(new Car { someVariableName })", Style);
1199 verifyFormat(R"(new Car { someVariableName })", Style);
1201 Style);
1202 verifyFormat(R"(Apply(x => x.Name, x => () => x.ID);)", Style);
1203 verifyFormat(R"(bool[] xs = { true, true };)", Style);
1205 R"(taskContext.Factory.Run(async () => doThing(args);)", Style);
1206 verifyFormat(R"(catch (TestException) when (innerFinallyExecuted))", Style);
1207 verifyFormat(R"(private float[,] Values;)", Style);
1208 verifyFormat(R"(Result this[Index x] => Foo(x);)", Style);
1210 verifyFormat(R"(char[,,] rawCharArray = MakeCharacterGrid();)", Style);
1211 verifyFormat(R"(var (key, value))", Style);
1214 verifyFormat(R"(A == typeof(X) && someBool)", Style);
1220 Style);
1223 verifyFormat("lock (process)", Style);
1225 Style.SpacesInSquareBrackets = true;
1226 verifyFormat(R"(private float[ , ] Values;)", Style);
1227 verifyFormat(R"(string dirPath = args?[ 0 ];)", Style);
1228 verifyFormat(R"(char[ ,, ] rawCharArray = MakeCharacterGrid();)", Style);
1231 verifyFormat(R"(public (string name, int age) methodTuple() {})", Style);
1232 verifyFormat(R"(private (string name, int age) methodTuple() {})", Style);
1233 verifyFormat(R"(protected (string name, int age) methodTuple() {})", Style);
1234 verifyFormat(R"(virtual (string name, int age) methodTuple() {})", Style);
1235 verifyFormat(R"(extern (string name, int age) methodTuple() {})", Style);
1236 verifyFormat(R"(static (string name, int age) methodTuple() {})", Style);
1237 verifyFormat(R"(internal (string name, int age) methodTuple() {})", Style);
1238 verifyFormat(R"(abstract (string name, int age) methodTuple() {})", Style);
1239 verifyFormat(R"(sealed (string name, int age) methodTuple() {})", Style);
1240 verifyFormat(R"(override (string name, int age) methodTuple() {})", Style);
1241 verifyFormat(R"(async (string name, int age) methodTuple() {})", Style);
1242 verifyFormat(R"(unsafe (string name, int age) methodTuple() {})", Style);
1244 Style.SpacesInSquareBrackets = false;
1245 Style.SpaceBeforeSquareBrackets = true;
1246 verifyFormat("return a is [1, 2, 3];", Style);
1247 verifyFormat("return a is [..];", Style);
1248 Style.SpaceBeforeSquareBrackets = false;
1249 verifyFormat("return a is [1, 2, 3];", Style);
1250 verifyFormat("return a is [..];", Style);
1254 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1255 Style.SpacesInSquareBrackets = false;
1263 Style); // int? is nullable not a conditional expression.
1266 Style); // Nullables in function definitions.
1268 verifyFormat(R"(public float? Value;)", Style); // no space before `?`.
1271 Style); // An array of a nullable type.
1273 verifyFormat(R"(var x = (int?)y;)", Style); // Cast to a nullable type.
1275 verifyFormat(R"(var x = new MyContainer<int?>();)", Style); // Generics.
1281 Style); // Interface methods.
1283 Style.ColumnLimit = 10;
1290 Style); // ? sticks with identifier.
1294 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1300 Style);
1305 Style);
1309 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1311 EXPECT_TRUE(Style.BraceWrapping.SplitEmptyRecord);
1316 Style);
1328 Style, {tooling::Range(43, 13)});
1338 Style);
1344 Style);
1346 Style.ColumnLimit = 50; // Force lines to be wrapped.
1354 Style);
1366 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1367 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
1368 Style.BraceWrapping.AfterEnum = false;
1369 Style.AllowShortEnumsOnASingleLine = false;
1375 Style);
1380 Style);
1385 Style);
1390 Style);
1395 Style);
1397 Style.BraceWrapping.AfterEnum = true;
1398 Style.AllowShortEnumsOnASingleLine = false;
1405 Style);
1411 Style);
1417 Style);
1423 Style);
1429 Style);
1435 Style);
1441 Style);
1445 FormatStyle Style = getGoogleStyle(FormatStyle::LK_CSharp);
1446 Style.BreakBeforeBraces = FormatStyle::BS_Custom;
1447 Style.BraceWrapping.AfterClass = false;
1453 Style);
1458 Style);
1463 Style);
1468 Style);
1473 Style);
1479 Style);
1484 Style);
1489 Style);
1494 Style);
1499 Style);
1501 Style.BraceWrapping.AfterClass = true;
1508 Style);
1514 Style);
1520 Style);
1526 Style);
1532 Style);
1539 Style);
1545 Style);
1551 Style);
1557 Style);
1563 Style);
1569 Style);
1575 Style);
1579 FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
1580 Style.NamespaceIndentation = FormatStyle::NI_None;
1588 Style);
1596 Style);
1598 Style.NamespaceIndentation = FormatStyle::NI_Inner;
1609 Style);
1611 Style.NamespaceIndentation = FormatStyle::NI_All;
1619 Style);
1630 Style);
1634 FormatStyle Style = getMicrosoftStyle(FormatStyle::LK_CSharp);
1640 Style);
1644 auto Style = getLLVMStyle();
1645 Style.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Empty;
1652 Style);
1657 Style);
1661 FormatStyle Style = getLLVMStyle(FormatStyle::LK_CSharp);
1662 Style.NamespaceIndentation = FormatStyle::NI_All;
1663 Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Inline;
1667 Style);
1671 Style);
1677 Style);
1684 Style);