Added the StyleCop.Analyzers NuGet to enforce styles
- at this time there is no way to enforce the .editorconfig - we will have to duplicate the rules because the IDE uses the .editorconfig for some things and StyleCop adds some more
This commit is contained in:
Родитель
87e01c75a3
Коммит
8003af3738
|
@ -4,12 +4,18 @@ root = true
|
|||
|
||||
# Don't use tabs for indentation.
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_style = space
|
||||
# (Please don't specify an indent_size here; that has too many unintended consequences.)
|
||||
|
||||
# Code files
|
||||
[*.{cs,csx,vb,vbx}]
|
||||
indent_size = 4
|
||||
indent_style = tabs
|
||||
|
||||
# Code files
|
||||
[*.sln]
|
||||
indent_size = 4
|
||||
indent_style = tabs
|
||||
|
||||
# Xml project files
|
||||
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
|
||||
|
@ -23,10 +29,14 @@ indent_size = 2
|
|||
[*.json]
|
||||
indent_size = 2
|
||||
|
||||
# XML files
|
||||
[*.xml]
|
||||
indent_size = 2
|
||||
|
||||
# Dotnet code style settings:
|
||||
[*.{cs,vb}]
|
||||
# Sort using and Import directives with System.* appearing first
|
||||
dotnet_sort_system_directives_first = false
|
||||
dotnet_sort_system_directives_first = true
|
||||
# Avoid "this." and "Me." if not necessary
|
||||
dotnet_style_qualification_for_field = false:suggestion
|
||||
dotnet_style_qualification_for_property = false:suggestion
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RuleSet Name="Rules for Caboodle" Description="Code analysis rules for Caboodle." ToolsVersion="15.0">
|
||||
<IncludeAll Action="Warning" />
|
||||
<Rules AnalyzerId="Microsoft.CodeAnalysis.CSharp" RuleNamespace="Microsoft.CodeAnalysis.CSharp">
|
||||
<Rule Id="SA0001" Action="None" />
|
||||
<Rule Id="SA1101" Action="None" />
|
||||
<Rule Id="SA1311" Action="None" />
|
||||
<Rule Id="SA1400" Action="None" />
|
||||
<Rule Id="SA1503" Action="None" />
|
||||
<Rule Id="SA1513" Action="None" />
|
||||
<Rule Id="SA1516" Action="None" />
|
||||
<Rule Id="SA1600" Action="None" />
|
||||
<Rule Id="SA1601" Action="None" />
|
||||
<Rule Id="SA1633" Action="None" />
|
||||
<Rule Id="SA1652" Action="None" />
|
||||
<!--
|
||||
=================================================================================================================
|
||||
Rules that are configured in the stylecop.json file
|
||||
https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/Configuration.md
|
||||
=================================================================================================================
|
||||
SA1200: Using directives must be placed correctly.
|
||||
settings.orderingRules.systemUsingDirectivesFirst
|
||||
settings.orderingRules.usingDirectivesPlacement
|
||||
=================================================================================================================
|
||||
-->
|
||||
</Rules>
|
||||
</RuleSet>
|
|
@ -6,6 +6,8 @@ MinimumVisualStudioVersion = 10.0.40219.1
|
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{579F334C-FB7F-448A-A638-8FCB1CE53D93}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
Caboodle.ruleset = Caboodle.ruleset
|
||||
stylecop.json = stylecop.json
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{A14D061F-382D-4609-A3B0-E1D0BF7AB6AC}"
|
||||
|
|
|
@ -29,16 +29,14 @@
|
|||
<UseFullSemVerForNuGet>false</UseFullSemVerForNuGet>
|
||||
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||
<PackageLicenseUrl>https://go.microsoft.com/fwlink/?linkid=868961</PackageLicenseUrl>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
|
||||
<PackageProjectUrl>https://go.microsoft.com/fwlink/?linkid=868960</PackageProjectUrl>
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<UpgradeBackupLocation>
|
||||
</UpgradeBackupLocation>
|
||||
<OldToolsVersion>2.0</OldToolsVersion>
|
||||
<CodeAnalysisRuleSet>..\Caboodle.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.1.0-beta006" PrivateAssets="All" />
|
||||
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.2.0" PrivateAssets="All" />
|
||||
<AdditionalFiles Include="..\stylecop.json" />
|
||||
<Compile Include="**\*.shared.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.0' ">
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"$schema": "https://raw.githubusercontent.com/DotNetAnalyzers/StyleCopAnalyzers/master/StyleCop.Analyzers/StyleCop.Analyzers/Settings/stylecop.schema.json",
|
||||
|
||||
"settings": {
|
||||
"layoutRules": {
|
||||
"newlineAtEndOfFile": "require"
|
||||
},
|
||||
"indentation": {
|
||||
"useTabs": true
|
||||
},
|
||||
"orderingRules": {
|
||||
"systemUsingDirectivesFirst": true,
|
||||
"usingDirectivesPlacement": "outsideNamespace"
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче