Skip to content

Commit e56a567

Browse files
committed
Updated after review
1 parent 63434b7 commit e56a567

11 files changed

Lines changed: 36 additions & 36 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.CodeFixes/OrderingRules/UsingCodeFixProvider.UsingsSorter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private class UsingsSorter
4040
public UsingsSorter(StyleCopSettings settings, SemanticModel semanticModel, CompilationUnitSyntax compilationUnit, ImmutableArray<SyntaxTrivia> fileHeader)
4141
{
4242
this.separateSystemDirectives = settings.OrderingRules.SystemUsingDirectivesFirst;
43-
this.insertBlankLinesBetweenGroups = settings.OrderingRules.UseBlankLinesBetweenUsingGroups == OptionSetting.Require;
43+
this.insertBlankLinesBetweenGroups = settings.OrderingRules.BlankLinesBetweenUsingGroups == OptionSetting.Require;
4444

4545
this.semanticModel = semanticModel;
4646
this.fileHeader = fileHeader;

StyleCop.Analyzers/StyleCop.Analyzers.Test/LayoutRules/SA1516UsingGroupsUnitTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace StyleCop.Analyzers.Test.LayoutRules
2222
public class SA1516UsingGroupsUnitTests : CodeFixVerifier
2323
{
2424
private bool? systemUsingDirectivesFirst;
25-
private OptionSetting? useBlankLinesBetweenUsingGroups;
25+
private OptionSetting? blankLinesBetweenUsingGroups;
2626

2727
/// <summary>
2828
/// Verifies the allow scenario is handled properly.
@@ -34,7 +34,7 @@ public class SA1516UsingGroupsUnitTests : CodeFixVerifier
3434
[InlineData("Test")]
3535
public async Task TestAllowForCompilationUnitAsync(string namespaceName)
3636
{
37-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Allow;
37+
this.blankLinesBetweenUsingGroups = OptionSetting.Allow;
3838

3939
var testCode = @"
4040
using System;
@@ -63,7 +63,7 @@ public async Task TestAllowForCompilationUnitAsync(string namespaceName)
6363
public async Task TestOmitWithSystemFirstAsync(string namespaceName)
6464
{
6565
this.systemUsingDirectivesFirst = true;
66-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Omit;
66+
this.blankLinesBetweenUsingGroups = OptionSetting.Omit;
6767

6868
var testCode = @"
6969
using System;
@@ -117,7 +117,7 @@ namespace TestNamespace
117117
public async Task TestOmitWithoutSystemFirstAsync(string namespaceName)
118118
{
119119
this.systemUsingDirectivesFirst = false;
120-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Omit;
120+
this.blankLinesBetweenUsingGroups = OptionSetting.Omit;
121121

122122
var testCode = @"
123123
using System;
@@ -169,7 +169,7 @@ namespace TestNamespace
169169
public async Task TestOmitWithSeparingCommentsAsync(string namespaceName)
170170
{
171171
this.systemUsingDirectivesFirst = true;
172-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Omit;
172+
this.blankLinesBetweenUsingGroups = OptionSetting.Omit;
173173

174174
var testCode = @"
175175
using System;
@@ -201,7 +201,7 @@ namespace TestNamespace
201201
public async Task TestRequireWithSystemFirstAsync(string namespaceName)
202202
{
203203
this.systemUsingDirectivesFirst = true;
204-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Require;
204+
this.blankLinesBetweenUsingGroups = OptionSetting.Require;
205205

206206
var testCode = @"
207207
using System;
@@ -255,7 +255,7 @@ namespace TestNamespace
255255
public async Task TestRequireWithoutSystemFirstAsync(string namespaceName)
256256
{
257257
this.systemUsingDirectivesFirst = false;
258-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Require;
258+
this.blankLinesBetweenUsingGroups = OptionSetting.Require;
259259

260260
var testCode = @"
261261
using System;
@@ -299,15 +299,15 @@ namespace TestNamespace
299299
/// <inheritdoc/>
300300
protected override string GetSettings()
301301
{
302-
var useBlankLinesBetweenUsingGroups = this.useBlankLinesBetweenUsingGroups ?? OptionSetting.Allow;
302+
var useBlankLinesBetweenUsingGroups = this.blankLinesBetweenUsingGroups ?? OptionSetting.Allow;
303303
var systemUsingDirectivesFirst = this.systemUsingDirectivesFirst ?? true;
304304

305305
return $@"
306306
{{
307307
""settings"": {{
308308
""orderingRules"": {{
309309
""systemUsingDirectivesFirst"" : {systemUsingDirectivesFirst.ToString().ToLowerInvariant()},
310-
""useBlankLinesBetweenUsingGroups"": ""{this.useBlankLinesBetweenUsingGroups.ToString().ToLowerInvariant()}""
310+
""blankLinesBetweenUsingGroups"": ""{this.blankLinesBetweenUsingGroups.ToString().ToLowerInvariant()}""
311311
}}
312312
}}
313313
}}

StyleCop.Analyzers/StyleCop.Analyzers.Test/OrderingRules/UsingCodeFixProviderGroupSeparationUnitTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace StyleCop.Analyzers.Test.OrderingRules
1515

1616
/// <summary>
1717
/// Unit tests for the <see cref="UsingCodeFixProvider"/> for the special case where
18-
/// <see cref="OrderingSettings.UseBlankLinesBetweenUsingGroups"/> is <see cref="OptionSetting.Require"/>.
18+
/// <see cref="OrderingSettings.BlankLinesBetweenUsingGroups"/> is <see cref="OptionSetting.Require"/>.
1919
/// </summary>
2020
public class UsingCodeFixProviderGroupSeparationUnitTests : CodeFixVerifier
2121
{
@@ -81,7 +81,7 @@ protected override string GetSettings()
8181
""settings"": {{
8282
""orderingRules"": {{
8383
""systemUsingDirectivesFirst"" : {systemUsingDirectivesFirst.ToString().ToLowerInvariant()},
84-
""useBlankLinesBetweenUsingGroups"": ""require""
84+
""blankLinesBetweenUsingGroups"": ""require""
8585
}}
8686
}}
8787
}}

StyleCop.Analyzers/StyleCop.Analyzers.Test/Settings/SettingsUnitTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void VerifySettingsDefaults()
3131

3232
Assert.NotNull(styleCopSettings.OrderingRules);
3333
Assert.Equal(UsingDirectivesPlacement.InsideNamespace, styleCopSettings.OrderingRules.UsingDirectivesPlacement);
34-
Assert.Equal(OptionSetting.Allow, styleCopSettings.OrderingRules.UseBlankLinesBetweenUsingGroups);
34+
Assert.Equal(OptionSetting.Allow, styleCopSettings.OrderingRules.BlankLinesBetweenUsingGroups);
3535

3636
Assert.NotNull(styleCopSettings.LayoutRules);
3737
Assert.Equal(OptionSetting.Allow, styleCopSettings.LayoutRules.NewlineAtEndOfFile);
@@ -64,7 +64,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync()
6464
},
6565
""orderingRules"": {
6666
""usingDirectivesPlacement"": ""outsideNamespace"",
67-
""useBlankLinesBetweenUsingGroups"": ""omit"",
67+
""blankLinesBetweenUsingGroups"": ""omit"",
6868
}
6969
}
7070
}
@@ -83,7 +83,7 @@ public async Task VerifySettingsAreReadCorrectlyAsync()
8383

8484
Assert.NotNull(styleCopSettings.OrderingRules);
8585
Assert.Equal(UsingDirectivesPlacement.OutsideNamespace, styleCopSettings.OrderingRules.UsingDirectivesPlacement);
86-
Assert.Equal(OptionSetting.Omit, styleCopSettings.OrderingRules.UseBlankLinesBetweenUsingGroups);
86+
Assert.Equal(OptionSetting.Omit, styleCopSettings.OrderingRules.BlankLinesBetweenUsingGroups);
8787
}
8888

8989
/// <summary>

StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingDirectiveSyntaxHelpers.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,30 +58,30 @@ internal static bool IsPrecededByPreprocessorDirective(this UsingDirectiveSyntax
5858
internal static bool HasNamespaceAliasQualifier(this UsingDirectiveSyntax usingDirective) => usingDirective.DescendantNodes().Any(node => node.IsKind(SyntaxKind.AliasQualifiedName));
5959

6060
/// <summary>
61-
/// Get the <see cref="UsingGroupType"/> for the give using directive.
61+
/// Get the <see cref="UsingGroup"/> for the give using directive.
6262
/// </summary>
6363
/// <param name="usingDirective">The <see cref="UsingDirectiveSyntax"/> that will be used.</param>
6464
/// <param name="settings">The <see cref="StyleCopSettings"/> that will be used.</param>
65-
/// <returns>The <see cref="UsingGroupType"/> for the given <paramref name="usingDirective"/>.</returns>
66-
internal static UsingGroupType GetUsingGroupType(this UsingDirectiveSyntax usingDirective, StyleCopSettings settings)
65+
/// <returns>The <see cref="UsingGroup"/> for the given <paramref name="usingDirective"/>.</returns>
66+
internal static UsingGroup GetUsingGroupType(this UsingDirectiveSyntax usingDirective, StyleCopSettings settings)
6767
{
6868
if (usingDirective.StaticKeyword.IsKind(SyntaxKind.StaticKeyword))
6969
{
70-
return UsingGroupType.Static;
70+
return UsingGroup.Static;
7171
}
7272

7373
if (usingDirective.Alias != null)
7474
{
75-
return UsingGroupType.Alias;
75+
return UsingGroup.Alias;
7676
}
7777

7878
if (settings.OrderingRules.SystemUsingDirectivesFirst
7979
&& usingDirective.IsSystemUsingDirective())
8080
{
81-
return UsingGroupType.System;
81+
return UsingGroup.System;
8282
}
8383

84-
return UsingGroupType.Regular;
84+
return UsingGroup.Regular;
8585
}
8686

8787
private static bool ExcludeGlobalKeyword(IdentifierNameSyntax token) => !token.Identifier.IsKind(SyntaxKind.GlobalKeyword);

StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingGroupType.cs renamed to StyleCop.Analyzers/StyleCop.Analyzers/Helpers/UsingGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace StyleCop.Analyzers.Helpers
66
/// <summary>
77
/// Using directive group type definitions.
88
/// </summary>
9-
internal enum UsingGroupType
9+
internal enum UsingGroup
1010
{
1111
/// <summary>
1212
/// The using directive group type is not known.

StyleCop.Analyzers/StyleCop.Analyzers/LayoutRules/SA1516ElementsMustBeSeparatedByBlankLine.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private static void HandleUsings(SyntaxNodeAnalysisContext context, SyntaxList<U
223223
return;
224224
}
225225

226-
var useBlankLinesBetweenUsingGroups = settings.OrderingRules.UseBlankLinesBetweenUsingGroups;
226+
var blankLinesBetweenUsingGroups = settings.OrderingRules.BlankLinesBetweenUsingGroups;
227227

228228
var previousGroupType = usings[0].GetUsingGroupType(settings);
229229
var previousLineSpan = usings[0].GetLineSpan();
@@ -245,7 +245,7 @@ private static void HandleUsings(SyntaxNodeAnalysisContext context, SyntaxList<U
245245
continue;
246246
}
247247

248-
if (useBlankLinesBetweenUsingGroups == OptionSetting.Require)
248+
if (blankLinesBetweenUsingGroups == OptionSetting.Require)
249249
{
250250
if (lineDistance > 1)
251251
{
@@ -258,7 +258,7 @@ private static void HandleUsings(SyntaxNodeAnalysisContext context, SyntaxList<U
258258

259259
context.ReportDiagnostic(Diagnostic.Create(DescriptorRequire, usings[i].UsingKeyword.GetLocation(), DiagnosticPropertiesRequire));
260260
}
261-
else if (useBlankLinesBetweenUsingGroups == OptionSetting.Omit)
261+
else if (blankLinesBetweenUsingGroups == OptionSetting.Omit)
262262
{
263263
if (lineDistance < 2)
264264
{

StyleCop.Analyzers/StyleCop.Analyzers/Settings/ObjectModel/OrderingSettings.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ internal class OrderingSettings
3636
private UsingDirectivesPlacement usingDirectivesPlacement;
3737

3838
/// <summary>
39-
/// This is the backing field for the <see cref="UseBlankLinesBetweenUsingGroups"/> property.
39+
/// This is the backing field for the <see cref="BlankLinesBetweenUsingGroups"/> property.
4040
/// </summary>
41-
[JsonProperty("useBlankLinesBetweenUsingGroups", DefaultValueHandling = DefaultValueHandling.Include)]
42-
private OptionSetting useBlankLinesBetweenUsingGroups;
41+
[JsonProperty("blankLinesBetweenUsingGroups", DefaultValueHandling = DefaultValueHandling.Include)]
42+
private OptionSetting blankLinesBetweenUsingGroups;
4343

4444
/// <summary>
4545
/// Initializes a new instance of the <see cref="OrderingSettings"/> class during JSON deserialization.
@@ -50,7 +50,7 @@ protected internal OrderingSettings()
5050
this.elementOrder = ImmutableArray.CreateBuilder<OrderingTrait>();
5151
this.systemUsingDirectivesFirst = true;
5252
this.usingDirectivesPlacement = UsingDirectivesPlacement.InsideNamespace;
53-
this.useBlankLinesBetweenUsingGroups = OptionSetting.Allow;
53+
this.blankLinesBetweenUsingGroups = OptionSetting.Allow;
5454
}
5555

5656
public ImmutableArray<OrderingTrait> ElementOrder
@@ -67,7 +67,7 @@ public ImmutableArray<OrderingTrait> ElementOrder
6767
public UsingDirectivesPlacement UsingDirectivesPlacement =>
6868
this.usingDirectivesPlacement;
6969

70-
public OptionSetting UseBlankLinesBetweenUsingGroups =>
71-
this.useBlankLinesBetweenUsingGroups;
70+
public OptionSetting BlankLinesBetweenUsingGroups =>
71+
this.blankLinesBetweenUsingGroups;
7272
}
7373
}

StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
],
9292
"default": "insideNamespace"
9393
},
94-
"useBlankLinesBetweenUsingGroups": {
94+
"blankLinesBetweenUsingGroups": {
9595
"type": "string",
9696
"description": "Specifies if using groups should be separated by a blank line.\r\nallow: A blank line is allowed, but not required\r\nrequire: A blank line is required\r\nomit: A blank line is not allowed",
9797
"enum": [

StyleCop.Analyzers/StyleCop.Analyzers/StyleCop.Analyzers.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
<Compile Include="Helpers\TokenHelper.cs" />
135135
<Compile Include="Helpers\TriviaHelper.cs" />
136136
<Compile Include="Helpers\UsingDirectiveSyntaxHelpers.cs" />
137-
<Compile Include="Helpers\UsingGroupType.cs" />
137+
<Compile Include="Helpers\UsingGroup.cs" />
138138
<Compile Include="Helpers\XmlCommentHelper.cs" />
139139
<Compile Include="Helpers\XmlFileHeader.cs" />
140140
<Compile Include="Helpers\XmlSyntaxFactory.cs" />

0 commit comments

Comments
 (0)