Skip to content

Commit

Permalink
Merge pull request #16 from sharwell/stylecop
Browse files Browse the repository at this point in the history
Enable StyleCop Analyzers and fix diagnostics
  • Loading branch information
sharwell authored Aug 21, 2018
2 parents b2482a3 + 865c1b3 commit 9dd23c2
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 10 deletions.
92 changes: 92 additions & 0 deletions JustMyCodeToggle.ruleset
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for JustMyCodeToggle" Description="Code analysis rules for JustMyCodeToggle." ToolsVersion="15.0">
<Rules AnalyzerId="Microsoft.Analyzers.ManagedCodeAnalysis" RuleNamespace="Microsoft.Rules.Managed">
<Rule Id="CA1001" Action="Warning" />
<Rule Id="CA1009" Action="Warning" />
<Rule Id="CA1016" Action="Warning" />
<Rule Id="CA1033" Action="Warning" />
<Rule Id="CA1049" Action="Warning" />
<Rule Id="CA1060" Action="Warning" />
<Rule Id="CA1061" Action="Warning" />
<Rule Id="CA1063" Action="Warning" />
<Rule Id="CA1065" Action="Warning" />
<Rule Id="CA1301" Action="Warning" />
<Rule Id="CA1400" Action="Warning" />
<Rule Id="CA1401" Action="Warning" />
<Rule Id="CA1403" Action="Warning" />
<Rule Id="CA1404" Action="Warning" />
<Rule Id="CA1405" Action="Warning" />
<Rule Id="CA1410" Action="Warning" />
<Rule Id="CA1415" Action="Warning" />
<Rule Id="CA1821" Action="Warning" />
<Rule Id="CA1900" Action="Warning" />
<Rule Id="CA1901" Action="Warning" />
<Rule Id="CA2002" Action="Warning" />
<Rule Id="CA2100" Action="Warning" />
<Rule Id="CA2101" Action="Warning" />
<Rule Id="CA2108" Action="Warning" />
<Rule Id="CA2111" Action="Warning" />
<Rule Id="CA2112" Action="Warning" />
<Rule Id="CA2114" Action="Warning" />
<Rule Id="CA2116" Action="Warning" />
<Rule Id="CA2117" Action="Warning" />
<Rule Id="CA2122" Action="Warning" />
<Rule Id="CA2123" Action="Warning" />
<Rule Id="CA2124" Action="Warning" />
<Rule Id="CA2126" Action="Warning" />
<Rule Id="CA2131" Action="Warning" />
<Rule Id="CA2132" Action="Warning" />
<Rule Id="CA2133" Action="Warning" />
<Rule Id="CA2134" Action="Warning" />
<Rule Id="CA2137" Action="Warning" />
<Rule Id="CA2138" Action="Warning" />
<Rule Id="CA2140" Action="Warning" />
<Rule Id="CA2141" Action="Warning" />
<Rule Id="CA2146" Action="Warning" />
<Rule Id="CA2147" Action="Warning" />
<Rule Id="CA2149" Action="Warning" />
<Rule Id="CA2200" Action="Warning" />
<Rule Id="CA2202" Action="Warning" />
<Rule Id="CA2207" Action="Warning" />
<Rule Id="CA2212" Action="Warning" />
<Rule Id="CA2213" Action="Warning" />
<Rule Id="CA2214" Action="Warning" />
<Rule Id="CA2216" Action="Warning" />
<Rule Id="CA2220" Action="Warning" />
<Rule Id="CA2229" Action="Warning" />
<Rule Id="CA2231" Action="Warning" />
<Rule Id="CA2232" Action="Warning" />
<Rule Id="CA2235" Action="Warning" />
<Rule Id="CA2236" Action="Warning" />
<Rule Id="CA2237" Action="Warning" />
<Rule Id="CA2238" Action="Warning" />
<Rule Id="CA2240" Action="Warning" />
<Rule Id="CA2241" Action="Warning" />
<Rule Id="CA2242" Action="Warning" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
<Rule Id="CS1573" Action="Hidden" />
<Rule Id="CS1591" Action="Hidden" />
<Rule Id="CS1712" Action="Hidden" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp.Features" RuleNamespace="Microsoft.CodeAnalysis.CSharp.Features">
<!-- IDE0003 duplicates functionality provided by SX1101 -->
<Rule Id="IDE0003" Action="None" />
</Rules>
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1139" Action="None" /> <!-- https://github.com/DotNetAnalyzers/StyleCopAnalyzers/issues/2275 -->
<Rule Id="SA1202" Action="None" />
<Rule Id="SA1204" Action="None" />
<Rule Id="SA1309" Action="None" />
<Rule Id="SA1412" Action="Warning" />
<Rule Id="SA1600" Action="None" />
<Rule Id="SA1601" Action="None" />
<Rule Id="SA1602" Action="None" />
<Rule Id="SA1611" Action="None" />
<Rule Id="SA1615" Action="None" />
<Rule Id="SX1101" Action="Warning" />
<Rule Id="SX1309" Action="Warning" />
<Rule Id="SX1309S" Action="Warning" />
</Rules>
</RuleSet>
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ namespace Tvl.VisualStudio.JustMyCodeToggle

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

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

public static readonly int cmdidJustMyCodeToggle = 0x0100;
public static readonly int CmdidJustMyCodeToggle = 0x0100;
}
}
7 changes: 3 additions & 4 deletions Tvl.VisualStudio.JustMyCodeToggle/JustMyCodeTogglePackage.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// Copyright (c) Tunnel Vision Laboratories, LLC. All Rights Reserved.
// Licensed under the MIT License. See LICENSE.txt in the project root for license information.

using Microsoft;

namespace Tvl.VisualStudio.JustMyCodeToggle
{
using System;
using System.ComponentModel.Design;
using System.Runtime.InteropServices;
using System.Threading;
using Microsoft;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell;
using IMenuCommandService = System.ComponentModel.Design.IMenuCommandService;
using Task = System.Threading.Tasks.Task;

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

public JustMyCodeTogglePackage()
{
var id = new CommandID(JustMyCodeToggleConstants.guidJustMyCodeToggleCommandSet, JustMyCodeToggleConstants.cmdidJustMyCodeToggle);
var id = new CommandID(JustMyCodeToggleConstants.GuidJustMyCodeToggleCommandSet, JustMyCodeToggleConstants.CmdidJustMyCodeToggle);
EventHandler invokeHandler = HandleInvokeJustMyCodeToggle;
EventHandler changeHandler = HandleChangeJustMyCodeToggle;
EventHandler beforeQueryStatus = HandleBeforeQueryStatusJustMyCodeToggle;
Expand Down
4 changes: 2 additions & 2 deletions Tvl.VisualStudio.JustMyCodeToggle/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

[assembly: CLSCompliant(false)]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
<!-- This property disables extension deployment for command line builds; required for AppVeyor -->
<DeployExtension>False</DeployExtension>

<!-- Ideally this is always enabled, but that tends to hurt developer productivity -->
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
Expand All @@ -39,6 +42,18 @@
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>

<!-- StyleCop Analyzers configuration -->
<PropertyGroup>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\JustMyCodeToggle.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta008" PrivateAssets="all" />
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\stylecop.json" Link="stylecop.json" />
<None Include="$(CodeAnalysisRuleSet)" Condition="'$(CodeAnalysisRuleSet)' != ''" Link="%(Filename)%(Extension)" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="15.1.192" PrivateAssets="All" />
<PackageReference Include="Microsoft.VisualStudio.Shell.14.0" Version="14.0.23205" />
Expand Down
14 changes: 14 additions & 0 deletions stylecop.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
"settings": {
"documentationRules": {
"companyName": "Tunnel Vision Laboratories, LLC",
"copyrightText": "Copyright (c) {companyName}. All Rights Reserved.\nLicensed under the MIT License. See LICENSE.txt in the project root for license information.",
"xmlHeader": false,
"fileNamingConvention": "metadata"
},
"layoutRules": {
"newlineAtEndOfFile": "require"
}
}
}

0 comments on commit 9dd23c2

Please sign in to comment.