Replace legacy StyleCop(Plus) with StyleCopAnalyzers

Analyzers are enabled in the Debug configuration
only to avoid unnecessary overheads when compiling
normally.
This commit is contained in:
Paul Chote
2019-05-03 21:25:28 +00:00
committed by reaperrr
parent 353db73381
commit ba282865f1
20 changed files with 159 additions and 582 deletions

View File

@@ -96,37 +96,17 @@ check-scripts:
@luac -p $(shell find mods/*/maps/* -iname '*.lua')
@luac -p $(shell find lua/* -iname '*.lua')
check: core
check: dependencies
@echo
@echo "Compiling in debug mode..."
@$(MSBUILD) -t:build -p:Configuration=Debug
@echo
@echo "Checking runtime assemblies..."
@mono --debug OpenRA.Utility.exe all --check-runtime-assemblies $(WHITELISTED_OPENRA_ASSEMBLIES) $(WHITELISTED_THIRDPARTY_ASSEMBLIES) $(WHITELISTED_CORE_ASSEMBLIES)
@echo
@echo "Checking for explicit interface violations..."
@mono --debug OpenRA.Utility.exe all --check-explicit-interfaces
@echo
@echo "Checking for code style violations in OpenRA.Game..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Game
@echo
@echo "Checking for code style violations in OpenRA.Platforms.Default..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Platforms.Default
@echo
@echo "Checking for code style violations in OpenRA.Mods.Common..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Mods.Common
@echo
@echo "Checking for code style violations in OpenRA.Mods.Cnc..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Mods.Cnc
@echo
@echo "Checking for code style violations in OpenRA.Mods.D2k..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Mods.D2k
@echo
@echo "Checking for code style violations in OpenRA.Utility..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Utility
@echo
@echo "Checking for code style violations in OpenRA.Test..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Test
@echo
@echo "Checking for code style violations in OpenRA.Server..."
@mono --debug OpenRA.StyleCheck.exe OpenRA.Server
NUNIT_CONSOLE := $(shell test -f thirdparty/download/nunit3-console.exe && echo mono thirdparty/download/nunit3-console.exe || \
which nunit3-console 2>/dev/null || which nunit2-console 2>/dev/null || which nunit-console 2>/dev/null)

View File

@@ -16,6 +16,7 @@
<PlatformTarget>x86</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -61,7 +62,15 @@
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<None Include="App.config" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
<Target Name="PostProcess" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="$(IntermediateOutputPath)\$(TargetFileName).processed">
<Exec Command="$(TargetDir)/OpenRA.PostProcess.exe $(TargetPath) -LAA" />
<Touch Files="$(IntermediateOutputPath)\$(TargetFileName).processed" AlwaysCreate="true" />

View File

@@ -11,6 +11,7 @@
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -25,13 +26,19 @@
<HintPath>..\thirdparty\download\Eluant.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
<Private>False</Private>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
</Project>

View File

@@ -11,6 +11,7 @@
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -42,5 +43,13 @@
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj">
<Private>False</Private>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
</Project>

View File

@@ -11,6 +11,7 @@
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -33,5 +34,13 @@
<ProjectReference Include="..\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
<Private>False</Private>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
</Project>

View File

@@ -11,6 +11,7 @@
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -33,7 +34,15 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\OpenRA.Game\OpenRA.Game.csproj" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
<ItemGroup>
<Content Include="OpenRA.Platforms.Default.dll.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>

View File

@@ -14,6 +14,7 @@
<PlatformTarget>x86</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -23,4 +24,14 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
</Project>

View File

@@ -14,6 +14,7 @@
<PlatformTarget>x86</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -28,7 +29,15 @@
<ProjectReference Include="..\OpenRA.PostProcess\OpenRA.PostProcess.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
<Target Name="PostProcess" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="$(IntermediateOutputPath)\$(TargetFileName).processed">
<Exec Command="$(TargetDir)/OpenRA.PostProcess.exe $(TargetPath) -LAA" />
<Touch Files="$(IntermediateOutputPath)\$(TargetFileName).processed" AlwaysCreate="true" />

View File

@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="mods/common"></probing>
</assemblyBinding>
</runtime>
</configuration>

View File

@@ -1,34 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net461</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Optimize>true</Optimize>
<UseVSHostingProcess>false</UseVSHostingProcess>
<OutputPath>..</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<LangVersion>5</LangVersion>
<DebugSymbols>true</DebugSymbols>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
<Compile Include="**/*.cs" Exclude="$(DefaultItemExcludes)"/>
</ItemGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<Reference Include="StyleCop">
<HintPath>..\StyleCop.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
</Project>

View File

@@ -1,47 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2019 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, and is made available under the terms of the MS-PL license.
* For more information, see https://opensource.org/licenses/MS-PL
*/
#endregion
using System;
using System.IO;
using StyleCop;
namespace OpenRA.StyleCheck
{
class StyleCheck
{
public static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("Usage: OpenRA.StyleCheck.exe DIRECTORY");
Console.WriteLine("Check the *.cs source code files in a directory for code style violations.");
return;
}
var projectPath = Path.GetFullPath(args[0]);
var console = new StyleCopConsole(null, false, null, null, true);
var project = new CodeProject(0, projectPath, new Configuration(null));
foreach (var filePath in Directory.GetFiles(projectPath, "*.cs", SearchOption.AllDirectories))
console.Core.Environment.AddSourceCode(project, filePath, null);
var violationCount = 0;
console.ViolationEncountered += (object sender, ViolationEventArgs e) => {
violationCount++;
var path = e.SourceCode.Path.Replace(Directory.GetCurrentDirectory() + Path.DirectorySeparatorChar, "");
Console.WriteLine("{0}:L{1}: [{2}] {3}", path, e.LineNumber, e.Violation.Rule.CheckId, e.Message);
};
console.Start(new[] { project }, true);
if (violationCount > 0)
Environment.Exit(1);
else
Console.WriteLine("No violations encountered in {0}.", args[0]);
}
}
}

View File

@@ -10,6 +10,7 @@
<Platforms>x86</Platforms>
<PlatformTarget>x86</PlatformTarget>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -36,5 +37,13 @@
<ProjectReference Include="..\OpenRA.Mods.Common\OpenRA.Mods.Common.csproj">
<Private>False</Private>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
</Project>

View File

@@ -14,6 +14,7 @@
<PlatformTarget>x86</PlatformTarget>
<ExternalConsole>false</ExternalConsole>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<CodeAnalysisRuleSet>..\OpenRA.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<!-- Work around an issue where Rider does not detect files in the project root using the default glob -->
@@ -28,7 +29,15 @@
<ProjectReference Include="..\OpenRA.PostProcess\OpenRA.PostProcess.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" />
<AdditionalFiles Include="../stylecop.json" />
</ItemGroup>
<Target Name="DisableAnalyzers" BeforeTargets="CoreCompile" Condition="'$(Configuration)'=='Release'">
<!-- Disable code style analysis on Release builds to improve compile-time performance -->
<ItemGroup Condition="'$(Configuration)'=='Release'">
<Analyzer Remove="@(Analyzer)"/>
</ItemGroup>
</Target>
<Target Name="PostProcess" AfterTargets="Build" Inputs="$(TargetPath)" Outputs="$(IntermediateOutputPath)\$(TargetFileName).processed">
<Exec Command="$(TargetDir)/OpenRA.PostProcess.exe $(TargetPath) -LAA" />
<Touch Files="$(IntermediateOutputPath)\$(TargetFileName).processed" AlwaysCreate="true" />

54
OpenRA.ruleset Normal file
View File

@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="OpenRA Code Style" ToolsVersion="14.0">
<IncludeAll Action="Warning" />
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!-- Rules that conflict with OpenRA project style conventions -->
<Rule Id="SA0001" Action="None" /><!-- XmlCommentAnalysisDisabled -->
<Rule Id="SA1101" Action="None" /><!-- PrefixLocalCallsWithThis -->
<Rule Id="SA1117" Action="None" /><!-- ParametersMustBeOnSameLineOrSeparateLines -->
<Rule Id="SA1118" Action="None" /><!-- ParameterMustNotSpanMultipleLines -->
<Rule Id="SA1122" Action="None" /><!-- UseStringEmptyForEmptyStrings -->
<Rule Id="SA1124" Action="None" /><!-- DoNotUseRegions -->
<Rule Id="SA1127" Action="None" /><!-- GenericTypeConstraintsMustBeOnOwnLine -->
<Rule Id="SA1135" Action="None" /><!-- UsingDirectivesMustBeQualified -->
<Rule Id="SA1136" Action="None" /><!-- EnumValuesShouldBeOnSeparateLines -->
<Rule Id="SA1200" Action="None" /><!-- UsingDirectivesMustBePlacedCorrectly -->
<Rule Id="SA1201" Action="None" /><!-- ElementsMustAppearInTheCorrectOrder -->
<Rule Id="SA1202" Action="None" /><!-- ElementsMustBeOrderedByAccess -->
<Rule Id="SA1314" Action="None" /><!-- TypeParameterNamesMustBeginWithT -->
<Rule Id="SA1400" Action="None" /><!-- AccessModifierMustBeDeclared -->
<Rule Id="SA1401" Action="None" /><!-- FieldsMustBePrivate -->
<Rule Id="SA1402" Action="None" /><!-- FileMayOnlyContainASingleType -->
<Rule Id="SA1407" Action="None" /><!-- ArithmeticExpressionsMustDeclarePrecedence -->
<Rule Id="SA1501" Action="None" /><!-- StatementMustNotBeOnSingleLine -->
<Rule Id="SA1502" Action="None" /><!-- ElementMustNotBeOnSingleLine -->
<Rule Id="SA1503" Action="None" /><!-- BracesMustNotBeOmitted -->
<Rule Id="SA1519" Action="None" /><!-- BracesMustNotBeOmittedFromMultiLineChildStatement -->
<Rule Id="SA1520" Action="None" /><!-- UseBracesConsistently -->
<Rule Id="SA1600" Action="None" /><!-- ElementsMustBeDocumented -->
<Rule Id="SA1601" Action="None" /><!-- PartialElementsMustBeDocumented -->
<Rule Id="SA1602" Action="None" /><!-- EnumerationItemsMustBeDocumented -->
<Rule Id="SA1633" Action="None" /><!-- FileMustHaveHeader -->
<Rule Id="SA1649" Action="None" /><!-- FileNameMustMatchTypeName -->
<!-- Rules that could potentially be enabled after existing violations are fixed -->
<Rule Id="SA1002" Action="None" /><!-- SemicolonsMustBeSpacedCorrectly -->
<Rule Id="SA1027" Action="None" /><!-- UseTabsCorrectly -->
<Rule Id="SA1107" Action="None" /><!-- CodeMustNotContainMultipleStatementsOnOneLine -->
<Rule Id="SA1115" Action="None" /><!-- ParameterMustFollowComma -->
<Rule Id="SA1116" Action="None" /><!-- SplitParametersMustStartOnLineAfterDeclaration -->
<Rule Id="SA1119" Action="None" /><!-- StatementMustNotUseUnnecessaryParenthesis -->
<Rule Id="SA1128" Action="None" /><!-- ConstructorInitializerMustBeOnOwnLine -->
<Rule Id="SA1129" Action="None" /><!-- DoNotUseDefaultValueTypeConstructor -->
<Rule Id="SA1132" Action="None" /><!-- DoNotCombineFields -->
<Rule Id="SA1133" Action="None" /><!-- DoNotCombineAttributes -->
<Rule Id="SA1134" Action="None" /><!-- AttributesMustNotShareLine -->
<Rule Id="SA1204" Action="None" /><!-- StaticElementsMustAppearBeforeInstanceElements -->
<Rule Id="SA1214" Action="None" /><!-- ReadonlyElementsMustAppearBeforeNonReadonlyElements -->
<Rule Id="SA1413" Action="None" /><!-- UseTrailingCommasInMultiLineInitializers -->
<Rule Id="SA1500" Action="None" /><!-- BracesForMultiLineStatementsMustNotShareLine -->
<Rule Id="SA1509" Action="None" /><!-- OpeningBracesMustNotBePrecededByBlankLine -->
<Rule Id="SA1513" Action="None" /><!-- ClosingBraceMustBeFollowedByBlankLine -->
<Rule Id="SA1516" Action="None" /><!-- ElementsMustBeSeparatedByBlankLine -->
</Rules>
</RuleSet>

View File

@@ -176,8 +176,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tiberian Sun Lua scripts",
mods\ts\maps\fields-of-green\fields-of-green.lua = mods\ts\maps\fields-of-green\fields-of-green.lua
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.StyleCheck", "OpenRA.StyleCheck\OpenRA.StyleCheck.csproj", "{5FEAB6DC-4E81-4B63-958B-22FC3534C606}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRA.PostProcess", "OpenRA.PostProcess\OpenRA.PostProcess.csproj", "{EE63AF7E-92EA-48FB-81E2-53D7D92F8050}"
EndProject
Global
@@ -218,10 +216,6 @@ Global
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Debug|x86.Build.0 = Debug|x86
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|x86.ActiveCfg = Release|x86
{6CB8E1B7-6B36-4D93-8633-7C573E194AC4}.Release|x86.Build.0 = Release|x86
{5FEAB6DC-4E81-4B63-958B-22FC3534C606}.Debug|x86.ActiveCfg = Debug|x86
{5FEAB6DC-4E81-4B63-958B-22FC3534C606}.Debug|x86.Build.0 = Debug|x86
{5FEAB6DC-4E81-4B63-958B-22FC3534C606}.Release|x86.ActiveCfg = Release|x86
{5FEAB6DC-4E81-4B63-958B-22FC3534C606}.Release|x86.Build.0 = Release|x86
{EE63AF7E-92EA-48FB-81E2-53D7D92F8050}.Debug|x86.ActiveCfg = Debug|x86
{EE63AF7E-92EA-48FB-81E2-53D7D92F8050}.Debug|x86.Build.0 = Debug|x86
{EE63AF7E-92EA-48FB-81E2-53D7D92F8050}.Release|x86.ActiveCfg = Release|x86

View File

@@ -1,408 +0,0 @@
<StyleCopSettings Version="105">
<Parsers>
<Parser ParserId="StyleCop.CSharp.CsParser">
<ParserSettings>
<BooleanProperty Name="AnalyzeDesignerFiles">False</BooleanProperty>
</ParserSettings>
</Parser>
</Parsers>
<Analyzers>
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
<Rules>
<Rule Name="ElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="EnumerationItemsMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustContainValidXml">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PartialElementDocumentationMustHaveSummaryText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotHaveDefaultSummary">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustMatchElementParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementReturnValueDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="VoidReturnValueMustNotBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumented">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParametersMustBeDocumentedPartialClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustMatchTypeParameters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustDeclareParameterName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="GenericTypeParameterDocumentationMustHaveText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustMatchAccessors">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PropertySummaryDocumentationMustOmitSetAccessorWithRestrictedAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustNotBeCopiedAndPasted">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SingleLineCommentsMustNotUseDocumentationStyleSlashes">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustNotBeEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationTextMustContainWhitespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationMustMeetCharacterPercentage">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ConstructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DestructorSummaryDocumentationMustBeginWithStandardText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="DocumentationHeadersMustNotContainBlankLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludedDocumentationXPathDoesNotExist">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="IncludeNodeDoesNotContainValidFileAndPath">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="InheritDocMustBeUsedWithInheritingClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileMustHaveHeader">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustShowCopyright">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustHaveCopyrightText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustContainFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderFileNameDocumentationMustMatchFileName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderMustHaveValidCompanyText">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.SpacingRules">
<Rules>
<Rule Name="TabsMustNotBeUsed">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.LayoutRules">
<Rules>
<Rule Name="CurlyBracketsForMultiLineStatementsMustNotShareLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StatementMustNotBeOnSingleLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementMustNotBeOnSingleLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CurlyBracketsMustNotBeOmitted">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustBeSeparatedByBlankLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="OpeningCurlyBracketsMustNotBePrecededByBlankLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
<Rules>
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustAppearInTheCorrectOrder">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ElementsMustBeOrderedByAccess">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="StaticElementsMustAppearBeforeInstanceElements">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
<Rules>
<Rule Name="CodeMustNotContainMultipleStatementsOnOneLine">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="UseStringEmptyForEmptyStrings">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PrefixLocalCallsWithThis">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="PrefixCallsCorrectly">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParametersMustBeOnSameLineOrSeparateLines">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ParameterMustFollowComma">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="SplitParametersMustStartOnLineAfterDeclaration">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.MaintainabilityRules">
<Rules>
<Rule Name="AccessModifierMustBeDeclared">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FieldsMustBePrivate">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="FileMayOnlyContainASingleClass">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="ArithmeticExpressionsMustDeclarePrecedence">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
<Rules>
<Rule Name="FieldNamesMustNotUseHungarianNotation">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings />
</Analyzer>
<Analyzer AnalyzerId="StyleCopPlus.StyleCopPlusRules">
<Rules>
<Rule Name="CheckAllowedIndentationCharacters">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CheckWhetherLastCodeLineIsEmpty">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CodeLineMustNotBeLongerThan">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="MethodMustNotContainMoreLinesThan">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="AdvancedNamingRules">
<RuleSettings>
<BooleanProperty Name="Enabled">False</BooleanProperty>
</RuleSettings>
</Rule>
<Rule Name="CodeLineMustNotBeLongerThan">
<RuleSettings>
<BooleanProperty Name="Enabled">True</BooleanProperty>
</RuleSettings>
</Rule>
</Rules>
<AnalyzerSettings>
<StringProperty Name="SP2100_Limit">180:4</StringProperty>
</AnalyzerSettings>
</Analyzer>
</Analyzers>
</StyleCopSettings>

View File

@@ -136,33 +136,18 @@ function Test-Command
function Check-Command
{
echo "Compiling in debug configuration..."
dotnet build /p:Configuration=Debug /nologo
if ($lastexitcode -ne 0)
{
echo "Build failed."
}
if (CheckForUtility -eq 0)
{
echo "Checking for explicit interface violations..."
./OpenRA.Utility.exe all --check-explicit-interfaces
}
if (Test-Path OpenRA.StyleCheck.exe)
{
echo "Checking for code style violations in OpenRA.Platforms.Default..."
./OpenRA.StyleCheck.exe OpenRA.Platforms.Default
echo "Checking for code style violations in OpenRA.Game..."
./OpenRA.StyleCheck.exe OpenRA.Game
echo "Checking for code style violations in OpenRA.Mods.Common..."
./OpenRA.StyleCheck.exe OpenRA.Mods.Common
echo "Checking for code style violations in OpenRA.Mods.Cnc..."
./OpenRA.StyleCheck.exe OpenRA.Mods.Cnc
echo "Checking for code style violations in OpenRA.Mods.D2k..."
./OpenRA.StyleCheck.exe OpenRA.Mods.D2k
echo "Checking for code style violations in OpenRA.Utility..."
./OpenRA.StyleCheck.exe OpenRA.Utility
echo "Checking for code style violations in OpenRA.Test..."
./OpenRA.StyleCheck.exe OpenRA.Test
}
else
{
echo "OpenRA.StyleCheck.exe could not be found. Build the project first using the `"all`" command."
}
}
function Check-Scripts-Command

10
stylecop.json Normal file
View File

@@ -0,0 +1,10 @@
{
"settings": {
"indentation": {
"useTabs": true
},
"layoutRules": {
"newlineAtEndOfFile": "require"
}
}
}

View File

@@ -11,22 +11,6 @@ if (!(Test-Path "nuget.exe"))
(New-Object System.Net.WebClient).DownloadFile("https://dist.nuget.org/win-x86-commandline/latest/nuget.exe", $target)
}
if (!(Test-Path "StyleCopPlus.dll"))
{
echo "Fetching StyleCopPlus from NuGet."
./nuget.exe install StyleCopPlus.MSBuild -Version 4.7.49.5 -ExcludeVersion -Verbosity quiet -Source nuget.org
cp StyleCopPlus.MSBuild/tools/StyleCopPlus.dll .
rmdir StyleCopPlus.MSBuild -Recurse
}
if (!(Test-Path "StyleCop.dll"))
{
echo "Fetching StyleCop files from NuGet."
./nuget.exe install StyleCop.MSBuild -Version 4.7.49.0 -ExcludeVersion -Verbosity quiet -Source nuget.org
cp StyleCop.MSBuild/tools/StyleCop*.dll .
rmdir StyleCop.MSBuild -Recurse
}
if (!(Test-Path "ICSharpCode.SharpZipLib.dll"))
{
echo "Fetching ICSharpCode.SharpZipLib from NuGet."

View File

@@ -13,20 +13,6 @@ download_dir="${0%/*}/download"
mkdir -p "${download_dir}"
cd "${download_dir}" || exit 1
if [ ! -f StyleCopPlus.dll ]; then
echo "Fetching StyleCopPlus from NuGet"
../noget.sh StyleCopPlus.MSBuild 4.7.49.5
cp ./StyleCopPlus.MSBuild/tools/StyleCopPlus.dll .
rm -rf StyleCopPlus.MSBuild
fi
if [ ! -f StyleCop.dll ]; then
echo "Fetching StyleCop files from NuGet"
../noget.sh StyleCop.MSBuild 4.7.49.0
cp ./StyleCop.MSBuild/tools/StyleCop*.dll .
rm -rf StyleCop.MSBuild
fi
if [ ! -f ICSharpCode.SharpZipLib.dll ]; then
echo "Fetching ICSharpCode.SharpZipLib from NuGet"
../noget.sh SharpZipLib 1.1.0