Skip to content

Commit 716489b

Browse files
committed
Replaced StyleCop add-on settings with analyzers package and stylecop.json
1 parent a05776a commit 716489b

15 files changed

+292
-209
lines changed

Examples/Examples.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<DefineConstants>DEBUG;TRACE</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
2424
<WarningLevel>4</WarningLevel>
25+
<CodeAnalysisRuleSet>Examples.ruleset</CodeAnalysisRuleSet>
26+
<DocumentationFile>bin\Debug\Examples.XML</DocumentationFile>
27+
<RunCodeAnalysis>true</RunCodeAnalysis>
2528
</PropertyGroup>
2629
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2730
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -31,6 +34,7 @@
3134
<DefineConstants>TRACE</DefineConstants>
3235
<ErrorReport>prompt</ErrorReport>
3336
<WarningLevel>4</WarningLevel>
37+
<CodeAnalysisRuleSet>Examples.ruleset</CodeAnalysisRuleSet>
3438
</PropertyGroup>
3539
<ItemGroup>
3640
<Reference Include="System" />
@@ -48,13 +52,21 @@
4852
</ItemGroup>
4953
<ItemGroup>
5054
<None Include="App.config" />
55+
<None Include="Examples.ruleset" />
56+
<None Include="packages.config" />
57+
<AdditionalFiles Include="stylecop.json" />
5158
</ItemGroup>
5259
<ItemGroup>
5360
<ProjectReference Include="..\Utility.CommandLine.Arguments\Utility.CommandLine.Arguments.csproj">
5461
<Project>{b739dd22-4bd3-4d17-a351-33d129e9fe30}</Project>
5562
<Name>Utility.CommandLine.Arguments</Name>
5663
</ProjectReference>
5764
</ItemGroup>
65+
<ItemGroup>
66+
<Analyzer Include="..\packages\StyleCop.Analyzers.1.1.0-beta001\analyzers\dotnet\cs\Newtonsoft.Json.dll" />
67+
<Analyzer Include="..\packages\StyleCop.Analyzers.1.1.0-beta001\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
68+
<Analyzer Include="..\packages\StyleCop.Analyzers.1.1.0-beta001\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
69+
</ItemGroup>
5870
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
5971
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
6072
Other similar extension points exist, see Microsoft.Common.targets.

Examples/Examples.ruleset

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules for Examples" Description="Code analysis rules for Examples.csproj." ToolsVersion="14.0">
3+
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
4+
<Rule Id="CA1001" Action="Warning" />
5+
<Rule Id="CA1009" Action="Warning" />
6+
<Rule Id="CA1016" Action="Warning" />
7+
<Rule Id="CA1033" Action="Warning" />
8+
<Rule Id="CA1049" Action="Warning" />
9+
<Rule Id="CA1060" Action="Warning" />
10+
<Rule Id="CA1061" Action="Warning" />
11+
<Rule Id="CA1063" Action="Warning" />
12+
<Rule Id="CA1065" Action="Warning" />
13+
<Rule Id="CA1301" Action="Warning" />
14+
<Rule Id="CA1400" Action="Warning" />
15+
<Rule Id="CA1401" Action="Warning" />
16+
<Rule Id="CA1403" Action="Warning" />
17+
<Rule Id="CA1404" Action="Warning" />
18+
<Rule Id="CA1405" Action="Warning" />
19+
<Rule Id="CA1410" Action="Warning" />
20+
<Rule Id="CA1415" Action="Warning" />
21+
<Rule Id="CA1821" Action="Warning" />
22+
<Rule Id="CA1900" Action="Warning" />
23+
<Rule Id="CA1901" Action="Warning" />
24+
<Rule Id="CA2002" Action="Warning" />
25+
<Rule Id="CA2100" Action="Warning" />
26+
<Rule Id="CA2101" Action="Warning" />
27+
<Rule Id="CA2108" Action="Warning" />
28+
<Rule Id="CA2111" Action="Warning" />
29+
<Rule Id="CA2112" Action="Warning" />
30+
<Rule Id="CA2114" Action="Warning" />
31+
<Rule Id="CA2116" Action="Warning" />
32+
<Rule Id="CA2117" Action="Warning" />
33+
<Rule Id="CA2122" Action="Warning" />
34+
<Rule Id="CA2123" Action="Warning" />
35+
<Rule Id="CA2124" Action="Warning" />
36+
<Rule Id="CA2126" Action="Warning" />
37+
<Rule Id="CA2131" Action="Warning" />
38+
<Rule Id="CA2132" Action="Warning" />
39+
<Rule Id="CA2133" Action="Warning" />
40+
<Rule Id="CA2134" Action="Warning" />
41+
<Rule Id="CA2137" Action="Warning" />
42+
<Rule Id="CA2138" Action="Warning" />
43+
<Rule Id="CA2140" Action="Warning" />
44+
<Rule Id="CA2141" Action="Warning" />
45+
<Rule Id="CA2146" Action="Warning" />
46+
<Rule Id="CA2147" Action="Warning" />
47+
<Rule Id="CA2149" Action="Warning" />
48+
<Rule Id="CA2200" Action="Warning" />
49+
<Rule Id="CA2202" Action="Warning" />
50+
<Rule Id="CA2207" Action="Warning" />
51+
<Rule Id="CA2212" Action="Warning" />
52+
<Rule Id="CA2213" Action="Warning" />
53+
<Rule Id="CA2214" Action="Warning" />
54+
<Rule Id="CA2216" Action="Warning" />
55+
<Rule Id="CA2220" Action="Warning" />
56+
<Rule Id="CA2229" Action="Warning" />
57+
<Rule Id="CA2231" Action="Warning" />
58+
<Rule Id="CA2232" Action="Warning" />
59+
<Rule Id="CA2235" Action="Warning" />
60+
<Rule Id="CA2236" Action="Warning" />
61+
<Rule Id="CA2237" Action="Warning" />
62+
<Rule Id="CA2238" Action="Warning" />
63+
<Rule Id="CA2240" Action="Warning" />
64+
<Rule Id="CA2241" Action="Warning" />
65+
<Rule Id="CA2242" Action="Warning" />
66+
</Rules>
67+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
68+
<Rule Id="SA1124" Action="None" />
69+
<Rule Id="SA1633" Action="None" />
70+
</Rules>
71+
</RuleSet>

Examples/Program.cs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,39 @@ internal class Program
1212
{
1313
#region Private Properties
1414

15+
/// <summary>
16+
/// Gets or sets a value indicating whether the Bool argument was supplied.
17+
/// </summary>
1518
[Argument('b', "boolean")]
1619
private static bool Bool { get; set; }
1720

21+
/// <summary>
22+
/// Gets or sets the value of the Double argument.
23+
/// </summary>
1824
[Argument('f', "float")]
1925
private static double Double { get; set; }
2026

27+
/// <summary>
28+
/// Gets or sets the value of the Int argument
29+
/// </summary>
2130
[Argument('i', "integer")]
2231
private static int Int { get; set; }
2332

33+
/// <summary>
34+
/// Gets or sets the value of the List argument.
35+
/// </summary>
2436
[Argument('l', "list")]
2537
private static List<int> List { get; set; }
2638

39+
/// <summary>
40+
/// Gets or sets the list of operands.
41+
/// </summary>
2742
[Operands]
2843
private static string[] Operands { get; set; }
2944

45+
/// <summary>
46+
/// Gets or sets the String argument.
47+
/// </summary>
3048
[Argument('s', "string")]
3149
private static string String { get; set; }
3250

@@ -41,7 +59,7 @@ internal class Program
4159
private static void Main(string[] args)
4260
{
4361
// enable ctrl+c
44-
Console.CancelKeyPress += delegate
62+
Console.CancelKeyPress += (o, e) =>
4563
{
4664
Environment.Exit(1);
4765
};
@@ -92,7 +110,7 @@ private static void Print(string commandLine)
92110
Console.WriteLine("Bool\t\t" + Bool);
93111
Console.WriteLine("Int\t\t" + Int);
94112
Console.WriteLine("Double\t\t" + Double);
95-
Console.WriteLine("List\t\t" + String.Join(",", List.Select(o => o.ToString())?.ToArray()));
113+
Console.WriteLine("List\t\t" + string.Join(",", List.Select(o => o.ToString())?.ToArray()));
96114

97115
Console.WriteLine("\r\nOperands\n-------");
98116

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
84
[assembly: AssemblyTitle("Examples")]
95
[assembly: AssemblyDescription("")]
106
[assembly: AssemblyConfiguration("")]
@@ -13,24 +9,7 @@
139
[assembly: AssemblyCopyright("Copyright © 2017")]
1410
[assembly: AssemblyTrademark("")]
1511
[assembly: AssemblyCulture("")]
16-
17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
19-
// COM, set the ComVisible attribute to true on that type.
2012
[assembly: ComVisible(false)]
21-
22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
2313
[assembly: Guid("45d85bd0-089d-4a40-9780-f23baf2eb221")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
3514
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
15+
[assembly: AssemblyFileVersion("1.0.0.0")]

Examples/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="StyleCop.Analyzers" version="1.1.0-beta001" targetFramework="net452" developmentDependency="true" />
4+
</packages>

Utility.CommandLine.Arguments.Tests/Arguments.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ public void PopulateCaseSensitive()
474474
}
475475

476476
/// <summary>
477-
/// Tests the <see cref="Utility.CommandLine.Arguments.Populate(Dictionary{string, string})"/> method.
477+
/// Tests the <see cref="Utility.CommandLine.Arguments.Populate(Dictionary{string, object})"/> method.
478478
/// </summary>
479479
[Fact]
480480
public void PopulateDictionary()
@@ -684,7 +684,7 @@ public class TestClassWithArrayOperands
684684

685685
/// <summary>
686686
/// Tests the <see cref="Utility.CommandLine.Arguments.Populate(Type, string)"/> method with an explicit string
687-
/// containing two operands, and with a Type containing a property of type <see cref="string[]"/> marked with the
687+
/// containing two operands, and with a Type containing a property of type <see langword="string[]"/> marked with the
688688
/// <see cref="Operands"/> attribute.
689689
/// </summary>
690690
[Fact]
@@ -708,6 +708,9 @@ public class TestClassWithArrayProperty
708708
{
709709
#region Private Properties
710710

711+
/// <summary>
712+
/// Gets or sets a test property.
713+
/// </summary>
711714
[CommandLine.Argument('a', "array")]
712715
private static string[] Array { get; set; }
713716

@@ -772,7 +775,7 @@ public class TestClassWithBadOperands
772775
/// <summary>
773776
/// Tests the <see cref="Utility.CommandLine.Arguments.Populate(Type, string)"/> method with an explicit string
774777
/// containing two operands, and with a Type containing a property marked with the <see cref="Operands"/> attribute but
775-
/// that is not of type <see cref="string[]"/> or <see cref="List{string}&gt;"/>}"/&gt; .
778+
/// that is not of type <see cref="T:string[]"/> or <see cref="List{T}"/>}"/&gt; .
776779
/// </summary>
777780
[Fact]
778781
public void PopulateOperands()
@@ -795,6 +798,9 @@ public class TestClassWithListProperty
795798
{
796799
#region Private Properties
797800

801+
/// <summary>
802+
/// Gets or sets a test property.
803+
/// </summary>
798804
[CommandLine.Argument('l', "list")]
799805
private static List<string> List { get; set; }
800806

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

5-
// General Information about an assembly is controlled through the following
6-
// set of attributes. Change these attribute values to modify the information
7-
// associated with an assembly.
84
[assembly: AssemblyTitle("Utility.CommandLine.Arguments.Tests")]
95
[assembly: AssemblyDescription("")]
106
[assembly: AssemblyConfiguration("")]
@@ -13,24 +9,7 @@
139
[assembly: AssemblyCopyright("Copyright © 2017")]
1410
[assembly: AssemblyTrademark("")]
1511
[assembly: AssemblyCulture("")]
16-
17-
// Setting ComVisible to false makes the types in this assembly not visible
18-
// to COM components. If you need to access a type in this assembly from
19-
// COM, set the ComVisible attribute to true on that type.
2012
[assembly: ComVisible(false)]
21-
22-
// The following GUID is for the ID of the typelib if this project is exposed to COM
2313
[assembly: Guid("9ceaac1f-cc94-4f0c-ba3d-4ef017734238")]
24-
25-
// Version information for an assembly consists of the following four values:
26-
//
27-
// Major Version
28-
// Minor Version
29-
// Build Number
30-
// Revision
31-
//
32-
// You can specify all the values or you can default the Build and Revision Numbers
33-
// by using the '*' as shown below:
34-
// [assembly: AssemblyVersion("1.0.*")]
3514
[assembly: AssemblyVersion("1.0.0.0")]
36-
[assembly: AssemblyFileVersion("1.0.0.0")]
15+
[assembly: AssemblyFileVersion("1.0.0.0")]

Utility.CommandLine.Arguments.Tests/Settings.StyleCop

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)