Skip to content

Commit 6acc49a

Browse files
Code review update: Split SA1402SettingsConfiguration.cs in two files.
1 parent 40992ba commit 6acc49a

3 files changed

Lines changed: 39 additions & 35 deletions

File tree

StyleCop.Analyzers/StyleCop.Analyzers.Test/MaintainabilityRules/SA1402SettingsConfiguration.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@
33

44
namespace StyleCop.Analyzers.Test.MaintainabilityRules
55
{
6-
using System.Collections.Generic;
7-
using System.Diagnostics.CodeAnalysis;
8-
using System.Linq;
9-
106
public enum SA1402SettingsConfiguration
117
{
128
/// <summary>
@@ -24,35 +20,4 @@ public enum SA1402SettingsConfiguration
2420
/// </summary>
2521
ConfigureAsNonTopLevelType,
2622
}
27-
28-
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1649:File name must match first type name.", Justification = "Extension method for enum above.")]
29-
public static class SA1402SettingsConfigurationExtensions
30-
{
31-
public static string GetSettings(this SA1402SettingsConfiguration configuration, string keyword)
32-
{
33-
if (configuration == SA1402SettingsConfiguration.KeepDefaultConfiguration)
34-
{
35-
return null;
36-
}
37-
38-
var keywords = new List<string> { "class", "interface", "struct", "enum", "delegate" };
39-
if (configuration == SA1402SettingsConfiguration.ConfigureAsNonTopLevelType)
40-
{
41-
keywords.Remove(keyword);
42-
}
43-
44-
var keywordsStr = string.Join(", ", keywords.Select(x => "\"" + x + "\""));
45-
46-
var settings = $@"
47-
{{
48-
""settings"": {{
49-
""maintainabilityRules"": {{
50-
""topLevelTypes"": [{keywordsStr}]
51-
}}
52-
}}
53-
}}";
54-
55-
return settings;
56-
}
57-
}
5823
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
2+
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
3+
4+
namespace StyleCop.Analyzers.Test.MaintainabilityRules
5+
{
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
9+
public static class SA1402SettingsConfigurationExtensions
10+
{
11+
public static string GetSettings(this SA1402SettingsConfiguration configuration, string keyword)
12+
{
13+
if (configuration == SA1402SettingsConfiguration.KeepDefaultConfiguration)
14+
{
15+
return null;
16+
}
17+
18+
var keywords = new List<string> { "class", "interface", "struct", "enum", "delegate" };
19+
if (configuration == SA1402SettingsConfiguration.ConfigureAsNonTopLevelType)
20+
{
21+
keywords.Remove(keyword);
22+
}
23+
24+
var keywordsStr = string.Join(", ", keywords.Select(x => "\"" + x + "\""));
25+
26+
var settings = $@"
27+
{{
28+
""settings"": {{
29+
""maintainabilityRules"": {{
30+
""topLevelTypes"": [{keywordsStr}]
31+
}}
32+
}}
33+
}}";
34+
35+
return settings;
36+
}
37+
}
38+
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
<Compile Include="MaintainabilityRules\SA1402ForClassUnitTests.cs" />
252252
<Compile Include="MaintainabilityRules\SA1402ForBlockDeclarationUnitTestsBase.cs" />
253253
<Compile Include="MaintainabilityRules\SA1402SettingsConfiguration.cs" />
254+
<Compile Include="MaintainabilityRules\SA1402SettingsConfigurationExtensions.cs" />
254255
<Compile Include="MaintainabilityRules\SA1403UnitTests.cs" />
255256
<Compile Include="MaintainabilityRules\SA1404UnitTests.cs" />
256257
<Compile Include="MaintainabilityRules\SA1405UnitTests.cs" />

0 commit comments

Comments
 (0)