261 references to PreferBracesPreference
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (17)
CodeActions\InitializeParameter\AddParameterCheckTests.cs (17)
2047
[InlineData((int)
PreferBracesPreference
.None)]
2048
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
2075
{ CSharpCodeStyleOptions.PreferBraces, new CodeStyleOption2<
PreferBracesPreference
>((
PreferBracesPreference
)preferBraces, NotificationOption2.Silent) },
2395
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.None },
2429
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.WhenMultiline },
2465
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.Always },
2498
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.None },
2531
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.WhenMultiline },
2567
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.Always },
2605
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.None },
2645
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.WhenMultiline},
2687
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.Always },
2726
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.None },
2765
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.WhenMultiline },
2807
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.Always },
2844
{ CSharpCodeStyleOptions.PreferBraces,
PreferBracesPreference
.None },
Microsoft.CodeAnalysis.CSharp.Features (6)
ExtractMethod\CSharpMethodExtractor.CSharpCodeGenerator.cs (1)
173
var useBlock = ((CSharpSimplifierOptions)this.ExtractMethodGenerationOptions.SimplifierOptions).PreferBraces.Value == CodeAnalysis.CodeStyle.
PreferBracesPreference
.Always;
InitializeParameter\CSharpAddParameterCheckCodeRefactoringProvider.cs (1)
61
var withBlock = options.PreferBraces.Value == CodeAnalysis.CodeStyle.
PreferBracesPreference
.Always;
src\Analyzers\CSharp\Analyzers\AddBraces\CSharpAddBracesDiagnosticAnalyzer.cs (3)
51
if (option.Value ==
PreferBracesPreference
.None ||
96
if (option.Value ==
PreferBracesPreference
.WhenMultiline
233
/// <see cref="
PreferBracesPreference
.WhenMultiline"/> preference due to the presence of braces on one or more
src\Analyzers\CSharp\Analyzers\CodeStyle\CSharpAnalyzerOptionsProvider.cs (1)
29
public CodeStyleOption2<
PreferBracesPreference
> PreferBraces => GetOption(CSharpCodeStyleOptions.PreferBraces);
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (211)
ExtractMethod\ExtractMethodCodeRefactoringTests.cs (2)
83
{ CSharpCodeStyleOptions.PreferBraces, new CodeStyleOption2<
PreferBracesPreference
>(
PreferBracesPreference
.None, NotificationOption2.Suggestion) }
src\Analyzers\CSharp\Tests\AddBraces\AddBracesTests.cs (209)
31
[InlineData((int)
PreferBracesPreference
.None)]
32
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
33
[InlineData((int)
PreferBracesPreference
.Always)]
48
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
51
[InlineData((int)
PreferBracesPreference
.None)]
52
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
53
[InlineData((int)
PreferBracesPreference
.Always)]
72
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
75
[InlineData((int)
PreferBracesPreference
.None)]
76
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
77
[InlineData((int)
PreferBracesPreference
.Always)]
92
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
95
[InlineData((int)
PreferBracesPreference
.None)]
96
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
97
[InlineData((int)
PreferBracesPreference
.Always)]
112
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
115
[InlineData((int)
PreferBracesPreference
.None)]
116
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
117
[InlineData((int)
PreferBracesPreference
.Always)]
132
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
135
[InlineData((int)
PreferBracesPreference
.None)]
136
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
137
[InlineData((int)
PreferBracesPreference
.Always)]
152
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
155
[InlineData((int)
PreferBracesPreference
.None)]
156
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
157
[InlineData((int)
PreferBracesPreference
.Always)]
173
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
176
[InlineData((int)
PreferBracesPreference
.None)]
177
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
178
[InlineData((int)
PreferBracesPreference
.Always)]
201
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
204
[InlineData((int)
PreferBracesPreference
.None)]
205
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
206
[InlineData((int)
PreferBracesPreference
.Always)]
236
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
239
[InlineData((int)
PreferBracesPreference
.None)]
240
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
241
[InlineData((int)
PreferBracesPreference
.Always)]
257
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
260
[InlineData((int)
PreferBracesPreference
.None)]
261
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
262
[InlineData((int)
PreferBracesPreference
.Always)]
278
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
281
[InlineData((int)
PreferBracesPreference
.None)]
282
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
283
[InlineData((int)
PreferBracesPreference
.Always)]
298
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
301
[InlineData((int)
PreferBracesPreference
.None, false)]
302
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
303
[InlineData((int)
PreferBracesPreference
.Always, true)]
330
(
PreferBracesPreference
)bracesPreference,
334
[InlineData((int)
PreferBracesPreference
.None, false)]
335
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
336
[InlineData((int)
PreferBracesPreference
.Always, true)]
361
(
PreferBracesPreference
)bracesPreference,
365
[InlineData((int)
PreferBracesPreference
.None, false)]
366
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
367
[InlineData((int)
PreferBracesPreference
.Always, true)]
379
(
PreferBracesPreference
)bracesPreference,
383
[InlineData((int)
PreferBracesPreference
.None, false)]
384
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
385
[InlineData((int)
PreferBracesPreference
.Always, true)]
412
(
PreferBracesPreference
)bracesPreference,
416
[InlineData((int)
PreferBracesPreference
.None, false)]
417
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
418
[InlineData((int)
PreferBracesPreference
.Always, true)]
445
(
PreferBracesPreference
)bracesPreference,
449
[InlineData((int)
PreferBracesPreference
.None, false)]
450
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
451
[InlineData((int)
PreferBracesPreference
.Always, true)]
477
(
PreferBracesPreference
)bracesPreference,
481
[InlineData((int)
PreferBracesPreference
.None, false)]
482
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
483
[InlineData((int)
PreferBracesPreference
.Always, true)]
510
(
PreferBracesPreference
)bracesPreference,
514
[InlineData((int)
PreferBracesPreference
.None, false)]
515
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
516
[InlineData((int)
PreferBracesPreference
.Always, true)]
551
(
PreferBracesPreference
)bracesPreference,
555
[InlineData((int)
PreferBracesPreference
.None, false)]
556
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
557
[InlineData((int)
PreferBracesPreference
.Always, true)]
596
(
PreferBracesPreference
)bracesPreference,
600
[InlineData((int)
PreferBracesPreference
.None, false)]
601
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
602
[InlineData((int)
PreferBracesPreference
.Always, true)]
640
(
PreferBracesPreference
)bracesPreference,
644
[InlineData((int)
PreferBracesPreference
.None, false)]
645
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
646
[InlineData((int)
PreferBracesPreference
.Always, true)]
684
(
PreferBracesPreference
)bracesPreference,
696
[InlineData((int)
PreferBracesPreference
.None, false)]
697
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
698
[InlineData((int)
PreferBracesPreference
.Always, true)]
736
(
PreferBracesPreference
)bracesPreference,
740
[InlineData((int)
PreferBracesPreference
.None, false)]
741
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
742
[InlineData((int)
PreferBracesPreference
.Always, true)]
767
(
PreferBracesPreference
)bracesPreference,
771
[InlineData((int)
PreferBracesPreference
.None, false)]
772
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
773
[InlineData((int)
PreferBracesPreference
.Always, true)]
802
(
PreferBracesPreference
)bracesPreference,
806
[InlineData((int)
PreferBracesPreference
.None, false)]
807
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
808
[InlineData((int)
PreferBracesPreference
.Always, true)]
835
(
PreferBracesPreference
)bracesPreference,
839
[InlineData((int)
PreferBracesPreference
.None, false)]
840
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
841
[InlineData((int)
PreferBracesPreference
.Always, true)]
869
(
PreferBracesPreference
)bracesPreference,
873
[InlineData((int)
PreferBracesPreference
.None, false)]
874
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
875
[InlineData((int)
PreferBracesPreference
.Always, true)]
900
(
PreferBracesPreference
)bracesPreference,
904
[InlineData((int)
PreferBracesPreference
.None, false)]
905
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
906
[InlineData((int)
PreferBracesPreference
.Always, true)]
931
(
PreferBracesPreference
)bracesPreference,
935
[InlineData((int)
PreferBracesPreference
.None, false)]
936
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
937
[InlineData((int)
PreferBracesPreference
.Always, true)]
963
(
PreferBracesPreference
)bracesPreference,
967
[InlineData((int)
PreferBracesPreference
.None, false)]
968
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
969
[InlineData((int)
PreferBracesPreference
.Always, true)]
997
(
PreferBracesPreference
)bracesPreference,
1001
[InlineData((int)
PreferBracesPreference
.None, false)]
1002
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
1003
[InlineData((int)
PreferBracesPreference
.Always, true)]
1031
(
PreferBracesPreference
)bracesPreference,
1035
[InlineData((int)
PreferBracesPreference
.None, false)]
1036
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1037
[InlineData((int)
PreferBracesPreference
.Always, true)]
1079
(
PreferBracesPreference
)bracesPreference,
1083
[InlineData((int)
PreferBracesPreference
.None, false)]
1084
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1085
[InlineData((int)
PreferBracesPreference
.Always, true)]
1145
(
PreferBracesPreference
)bracesPreference,
1149
[InlineData((int)
PreferBracesPreference
.None, false)]
1150
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1151
[InlineData((int)
PreferBracesPreference
.Always, true)]
1213
(
PreferBracesPreference
)bracesPreference,
1217
[InlineData((int)
PreferBracesPreference
.None, false)]
1218
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
1219
[InlineData((int)
PreferBracesPreference
.Always, true)]
1281
(
PreferBracesPreference
)bracesPreference,
1285
[InlineData((int)
PreferBracesPreference
.None, false)]
1286
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1287
[InlineData((int)
PreferBracesPreference
.Always, true)]
1315
(
PreferBracesPreference
)bracesPreference,
1319
[InlineData((int)
PreferBracesPreference
.None, false)]
1320
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1321
[InlineData((int)
PreferBracesPreference
.Always, true)]
1355
(
PreferBracesPreference
)bracesPreference,
1359
[InlineData((int)
PreferBracesPreference
.None)]
1360
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
1361
[InlineData((int)
PreferBracesPreference
.Always)]
1378
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
1381
[InlineData((int)
PreferBracesPreference
.None)]
1382
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
1383
[InlineData((int)
PreferBracesPreference
.Always)]
1400
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
1403
[InlineData((int)
PreferBracesPreference
.None)]
1404
[InlineData((int)
PreferBracesPreference
.WhenMultiline)]
1405
[InlineData((int)
PreferBracesPreference
.Always)]
1424
new TestParameters(options: Option(CSharpCodeStyleOptions.PreferBraces, (
PreferBracesPreference
)bracesPreference, NotificationOption2.Silent)));
1427
[InlineData((int)
PreferBracesPreference
.None, false)]
1428
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1429
[InlineData((int)
PreferBracesPreference
.Always, true)]
1466
(
PreferBracesPreference
)bracesPreference,
1470
[InlineData((int)
PreferBracesPreference
.None, false)]
1471
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1472
[InlineData((int)
PreferBracesPreference
.Always, true)]
1509
(
PreferBracesPreference
)bracesPreference,
1513
[InlineData((int)
PreferBracesPreference
.None, false)]
1514
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1515
[InlineData((int)
PreferBracesPreference
.Always, true)]
1552
(
PreferBracesPreference
)bracesPreference,
1556
[InlineData((int)
PreferBracesPreference
.None, false)]
1557
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1558
[InlineData((int)
PreferBracesPreference
.Always, true)]
1595
(
PreferBracesPreference
)bracesPreference,
1599
[InlineData((int)
PreferBracesPreference
.None, false)]
1600
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
1601
[InlineData((int)
PreferBracesPreference
.Always, true)]
1642
(
PreferBracesPreference
)bracesPreference,
1646
[InlineData((int)
PreferBracesPreference
.None, false)]
1647
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
1648
[InlineData((int)
PreferBracesPreference
.Always, true)]
1689
(
PreferBracesPreference
)bracesPreference,
1693
[InlineData((int)
PreferBracesPreference
.None, false)]
1694
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1695
[InlineData((int)
PreferBracesPreference
.Always, true)]
1728
(
PreferBracesPreference
)bracesPreference,
1732
[InlineData((int)
PreferBracesPreference
.None, false)]
1733
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1734
[InlineData((int)
PreferBracesPreference
.Always, true)]
1767
(
PreferBracesPreference
)bracesPreference,
1771
[InlineData((int)
PreferBracesPreference
.None, false)]
1772
[InlineData((int)
PreferBracesPreference
.WhenMultiline, false)]
1773
[InlineData((int)
PreferBracesPreference
.Always, true)]
1808
(
PreferBracesPreference
)bracesPreference,
1812
[InlineData((int)
PreferBracesPreference
.None, false)]
1813
[InlineData((int)
PreferBracesPreference
.WhenMultiline, true)]
1814
[InlineData((int)
PreferBracesPreference
.Always, true)]
1849
(
PreferBracesPreference
)bracesPreference,
1852
private async Task TestAsync(string initialMarkup, string expectedMarkup,
PreferBracesPreference
bracesPreference, bool expectDiagnostic)
Microsoft.CodeAnalysis.CSharp.Workspaces (20)
Simplification\Reducers\CSharpMiscellaneousReducer.cs (3)
131
case
PreferBracesPreference
.Always:
135
case
PreferBracesPreference
.WhenMultiline:
169
case
PreferBracesPreference
.None:
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\CSharpCodeStyleOptions.cs (1)
139
public static readonly Option2<CodeStyleOption2<
PreferBracesPreference
>> PreferBraces = CreateOption(
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\CodeStyle\CSharpCodeStyleOptions_Parsing.cs (13)
106
private static CodeStyleOption2<
PreferBracesPreference
> ParsePreferBracesPreference(
108
CodeStyleOption2<
PreferBracesPreference
> defaultValue)
119
? new CodeStyleOption2<
PreferBracesPreference
>(
PreferBracesPreference
.Always, notificationOption)
120
: new CodeStyleOption2<
PreferBracesPreference
>(
PreferBracesPreference
.None, notificationOption);
125
return new CodeStyleOption2<
PreferBracesPreference
>(
PreferBracesPreference
.WhenMultiline, notificationOption);
132
private static string GetPreferBracesPreferenceEditorConfigString(CodeStyleOption2<
PreferBracesPreference
> value, CodeStyleOption2<
PreferBracesPreference
> defaultValue)
137
PreferBracesPreference
.None => $"false{notificationString}",
138
PreferBracesPreference
.WhenMultiline => $"when_multiline{notificationString}",
139
PreferBracesPreference
.Always => $"true{notificationString}",
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Simplification\CSharpSimplifierOptions.cs (3)
18
private static readonly CodeStyleOption2<
PreferBracesPreference
> s_defaultPreferBraces =
19
new(
PreferBracesPreference
.Always, NotificationOption2.Silent);
30
[DataMember] public CodeStyleOption2<
PreferBracesPreference
> PreferBraces { get; init; } = s_defaultPreferBraces;
Microsoft.VisualStudio.LanguageServices.CSharp (7)
EditorConfigSettings\DataProvider\CodeStyle\CSharpCodeStyleSettingsProvider.cs (3)
97
enumValues: [
PreferBracesPreference
.Always,
PreferBracesPreference
.None,
PreferBracesPreference
.WhenMultiline],
Options\Formatting\StyleViewModel.cs (4)
2378
var enumValues = new[] {
PreferBracesPreference
.Always,
PreferBracesPreference
.None,
PreferBracesPreference
.WhenMultiline };
2380
CodeStyleItems.Add(new EnumCodeStyleOptionViewModel<
PreferBracesPreference
>(