Skip to content

Commit 865c1b3

Browse files
committed
Enable StyleCop Analyzers and fix diagnostics
1 parent b2482a3 commit 865c1b3

File tree

6 files changed

+130
-10
lines changed

6 files changed

+130
-10
lines changed

Diff for: JustMyCodeToggle.ruleset

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RuleSet Name="Rules for JustMyCodeToggle" Description="Code analysis rules for JustMyCodeToggle." ToolsVersion="15.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="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
68+
<Rule Id="CS1573" Action="Hidden" />
69+
<Rule Id="CS1591" Action="Hidden" />
70+
<Rule Id="CS1712" Action="Hidden" />
71+
</Rules>
72+
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.Features" RuleNamespace="Microsoft.CodeAnalysis.CSharp.Features">
73+
<!-- IDE0003 duplicates functionality provided by SX1101 -->
74+
<Rule Id="IDE0003" Action="None" />
75+
</Rules>
76+
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
77+
<Rule Id="SA1101" Action="None" />
78+
<Rule Id="SA1139" Action="None" /> <!-- https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2275 -->
79+
<Rule Id="SA1202" Action="None" />
80+
<Rule Id="SA1204" Action="None" />
81+
<Rule Id="SA1309" Action="None" />
82+
<Rule Id="SA1412" Action="Warning" />
83+
<Rule Id="SA1600" Action="None" />
84+
<Rule Id="SA1601" Action="None" />
85+
<Rule Id="SA1602" Action="None" />
86+
<Rule Id="SA1611" Action="None" />
87+
<Rule Id="SA1615" Action="None" />
88+
<Rule Id="SX1101" Action="Warning" />
89+
<Rule Id="SX1309" Action="Warning" />
90+
<Rule Id="SX1309S" Action="Warning" />
91+
</Rules>
92+
</RuleSet>

Diff for: Tvl.VisualStudio.JustMyCodeToggle/JustMyCodeToggleConstants.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace Tvl.VisualStudio.JustMyCodeToggle
77

88
internal static class JustMyCodeToggleConstants
99
{
10-
public const string guidJustMyCodeTogglePackageString = "73702199-D0C5-4863-8203-99D41B34DD2D";
10+
public const string GuidJustMyCodeTogglePackageString = "73702199-D0C5-4863-8203-99D41B34DD2D";
1111

12-
public const string guidJustMyCodeToggleCommandSetString = "B1317E30-CFDA-47CA-90A0-95E894B150A0";
13-
public static readonly Guid guidJustMyCodeToggleCommandSet = new Guid("{" + guidJustMyCodeToggleCommandSetString + "}");
12+
public const string GuidJustMyCodeToggleCommandSetString = "B1317E30-CFDA-47CA-90A0-95E894B150A0";
13+
public static readonly Guid GuidJustMyCodeToggleCommandSet = new Guid("{" + GuidJustMyCodeToggleCommandSetString + "}");
1414

15-
public static readonly int cmdidJustMyCodeToggle = 0x0100;
15+
public static readonly int CmdidJustMyCodeToggle = 0x0100;
1616
}
1717
}

Diff for: Tvl.VisualStudio.JustMyCodeToggle/JustMyCodeTogglePackage.cs

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
22
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.
33

4-
using Microsoft;
5-
64
namespace Tvl.VisualStudio.JustMyCodeToggle
75
{
86
using System;
97
using System.ComponentModel.Design;
108
using System.Runtime.InteropServices;
119
using System.Threading;
10+
using Microsoft;
1211
using Microsoft.VisualStudio;
1312
using Microsoft.VisualStudio.Shell;
1413
using IMenuCommandService = System.ComponentModel.Design.IMenuCommandService;
1514
using Task = System.Threading.Tasks.Task;
1615

17-
[Guid(JustMyCodeToggleConstants.guidJustMyCodeTogglePackageString)]
16+
[Guid(JustMyCodeToggleConstants.GuidJustMyCodeTogglePackageString)]
1817
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
1918
[ProvideMenuResource(1000, 1)]
2019
[ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExistsAndFullyLoaded_string, PackageAutoLoadFlags.BackgroundLoad)]
@@ -24,7 +23,7 @@ internal class JustMyCodeTogglePackage : AsyncPackage
2423

2524
public JustMyCodeTogglePackage()
2625
{
27-
var id = new CommandID(JustMyCodeToggleConstants.guidJustMyCodeToggleCommandSet, JustMyCodeToggleConstants.cmdidJustMyCodeToggle);
26+
var id = new CommandID(JustMyCodeToggleConstants.GuidJustMyCodeToggleCommandSet, JustMyCodeToggleConstants.CmdidJustMyCodeToggle);
2827
EventHandler invokeHandler = HandleInvokeJustMyCodeToggle;
2928
EventHandler changeHandler = HandleChangeJustMyCodeToggle;
3029
EventHandler beforeQueryStatus = HandleBeforeQueryStatusJustMyCodeToggle;

Diff for: Tvl.VisualStudio.JustMyCodeToggle/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
[assembly: CLSCompliant(false)]
88

9-
// Setting ComVisible to false makes the types in this assembly not visible
10-
// to COM components. If you need to access a type in this assembly from
9+
// Setting ComVisible to false makes the types in this assembly not visible
10+
// to COM components. If you need to access a type in this assembly from
1111
// COM, set the ComVisible attribute to true on that type.
1212
[assembly: ComVisible(false)]

Diff for: Tvl.VisualStudio.JustMyCodeToggle/Tvl.VisualStudio.JustMyCodeToggle.csproj

+15
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
2828
<!-- This property disables extension deployment for command line builds; required for AppVeyor -->
2929
<DeployExtension>False</DeployExtension>
30+
31+
<!-- Ideally this is always enabled, but that tends to hurt developer productivity -->
32+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
3033
</PropertyGroup>
3134

3235
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
@@ -39,6 +42,18 @@
3942
<DebugSymbols>true</DebugSymbols>
4043
</PropertyGroup>
4144

45+
<!-- StyleCop Analyzers configuration -->
46+
<PropertyGroup>
47+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
48+
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\JustMyCodeToggle.ruleset</CodeAnalysisRuleSet>
49+
</PropertyGroup>
50+
51+
<ItemGroup>
52+
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="all" />
53+
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\stylecop.json" Link="stylecop.json" />
54+
<None Include="$(CodeAnalysisRuleSet)" Condition="'$(CodeAnalysisRuleSet)' != ''" Link="%(Filename)%(Extension)" />
55+
</ItemGroup>
56+
4257
<ItemGroup>
4358
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.1.192" PrivateAssets="All" />
4459
<PackageReference Include="Microsoft.VisualStudio.Shell.14.0" Version="14.0.23205" />

Diff for: stylecop.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
3+
"settings": {
4+
"documentationRules": {
5+
"companyName": "Tunnel Vision Laboratories, LLC",
6+
"copyrightText": "Copyright (c) {companyName}. All Rights Reserved.\nLicensed under the MIT License. See LICENSE.txt in the project root for license information.",
7+
"xmlHeader": false,
8+
"fileNamingConvention": "metadata"
9+
},
10+
"layoutRules": {
11+
"newlineAtEndOfFile": "require"
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)