diff --git a/.gitignore b/.gitignore
index a057183f58..9553838c52 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,6 +22,7 @@ mods/*/*.mdb
/*.pdb
/*.mdb
/*.exe
+thirdparty/StyleCop*
# backup files by various editors
*~
@@ -57,6 +58,7 @@ Lua-API.md
# StyleCop
*.Cache
+StyleCopViolations.xml
# SublimeText
*.sublime-project
diff --git a/.travis.yml b/.travis.yml
index c8489f949c..559bc7c395 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,6 +9,7 @@ script:
- make cli-dependencies
- make all
- make test
+ - make check
# Automatically update the trait documentation and Lua API
after_success:
diff --git a/INSTALL.md b/INSTALL.md
index 48614c2a88..4754ec0f11 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -38,6 +38,7 @@ Debian/Ubuntu
* mono-dmcs
* libmono-system-windows-forms4.0-cil
+* nuget
* cli-common-dev (>= 2.10)
* libfreetype6
* libopenal1
@@ -50,6 +51,7 @@ openSUSE
--------
* mono-devel
+* nuget
* openal
* freetype2
* SDL2
@@ -62,6 +64,7 @@ Gentoo
* dev-lang/mono
* dev-dotnet/libgdiplus
+* dev-dotnet/nuget
* media-libs/freetype:2
* media-libs/libsdl2
* media-libs/openal
diff --git a/Makefile b/Makefile
index 384e550d12..42885e1768 100644
--- a/Makefile
+++ b/Makefile
@@ -67,7 +67,7 @@ INSTALL_PROGRAM = $(INSTALL) -m755
INSTALL_DATA = $(INSTALL) -m644
# program targets
-CORE = rsdl2 rnull game utility ralint
+CORE = rsdl2 rnull game utility
TOOLS = editor tsbuild crashdialog
VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev/null || echo git-`git rev-parse --short HEAD`)
@@ -105,14 +105,14 @@ mod_common_SRCS := $(shell find OpenRA.Mods.Common/ -iname '*.cs')
mod_common_TARGET = mods/common/OpenRA.Mods.Common.dll
mod_common_KIND = library
mod_common_DEPS = $(game_TARGET)
-mod_common_LIBS = $(COMMON_LIBS) $(STD_MOD_LIBS)
+mod_common_LIBS = $(COMMON_LIBS) $(STD_MOD_LIBS) thirdparty/StyleCop.dll thirdparty/StyleCop.CSharp.dll thirdparty/StyleCop.CSharp.Rules.dll
PROGRAMS += mod_common
mod_common: $(mod_common_TARGET)
##### Official Mods #####
STD_MOD_LIBS = $(game_TARGET)
-STD_MOD_DEPS = $(STD_MOD_LIBS) $(ralint_TARGET)
+STD_MOD_DEPS = $(STD_MOD_LIBS)
# Red Alert
mod_ra_SRCS := $(shell find OpenRA.Mods.RA/ -iname '*.cs')
@@ -168,24 +168,23 @@ OpenRA.Editor.Form1.resources:
resgen2 OpenRA.Editor/Form1.resx OpenRA.Editor.Form1.resources 1> /dev/null
editor: OpenRA.Editor.MapSelect.resources OpenRA.Editor.Form1.resources $(editor_TARGET)
-# Analyses mod yaml for easy to detect errors
-ralint_SRCS := $(shell find OpenRA.Lint/ -iname '*.cs')
-ralint_TARGET = OpenRA.Lint.exe
-ralint_KIND = exe
-ralint_DEPS = $(game_TARGET)
-ralint_LIBS = $(COMMON_LIBS) $(ralint_DEPS)
-PROGRAMS += ralint
-ralint: $(ralint_TARGET)
-
test:
- @echo "OpenRA.Lint: checking Red Alert mod MiniYAML..."
- @mono --debug OpenRA.Lint.exe --verbose ra
- @echo "OpenRA.Lint: checking Tiberian Dawn mod MiniYAML..."
- @mono --debug OpenRA.Lint.exe --verbose cnc
- @echo "OpenRA.Lint: checking Dune 2000 mod MiniYAML..."
- @mono --debug OpenRA.Lint.exe --verbose d2k
- @echo "OpenRA.Lint: checking Tiberian Sun mod MiniYAML..."
- @mono --debug OpenRA.Lint.exe --verbose ts
+ @echo "Testing Red Alert mod MiniYAML..."
+ @mono --debug OpenRA.Utility.exe ra --check-yaml
+ @echo "Testing Tiberian Dawn mod MiniYAML..."
+ @mono --debug OpenRA.Utility.exe cnc --check-yaml
+ @echo "Testing Dune 2000 mod MiniYAML..."
+ @mono --debug OpenRA.Utility.exe d2k --check-yaml
+ @echo "Testing Tiberian Sun mod MiniYAML..."
+ @mono --debug OpenRA.Utility.exe ts --check-yaml
+
+check:
+ @echo "Checking for code style violations in OpenRA.Renderer.Null..."
+ @mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.Renderer.Null
+ @echo "Checking for code style violations in OpenRA.GameMonitor..."
+ @mono --debug OpenRA.Utility.exe ra --check-code-style OpenRA.GameMonitor
+ @echo "Checking for code style violations in OpenRA.Mods.Cnc..."
+ @mono --debug OpenRA.Utility.exe cnc --check-code-style OpenRA.Mods.Cnc
# Builds and exports tilesets from a bitmap
tsbuild_SRCS := $(shell find OpenRA.TilesetBuilder/ -iname '*.cs')
@@ -254,7 +253,7 @@ $(foreach prog,$(PROGRAMS),$(eval $(call BUILD_ASSEMBLY,$(prog))))
#
default: cli-dependencies core
-core: game renderers mods utility ralint
+core: game renderers mods utility
tools: editor tsbuild gamemonitor
@@ -273,6 +272,7 @@ distclean: clean
dependencies: cli-dependencies native-dependencies
cli-dependencies:
+ cd thirdparty && ./fetch-thirdparty-deps.sh && cd ..
@ $(CP_R) thirdparty/*.dll .
@ $(CP_R) thirdparty/*.dll.config .
diff --git a/OpenRA.Game/Settings.StyleCop b/OpenRA.Game/Settings.StyleCop
deleted file mode 100644
index 1590d17baa..0000000000
--- a/OpenRA.Game/Settings.StyleCop
+++ /dev/null
@@ -1,344 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRA.GameMonitor/Settings.StyleCop b/OpenRA.GameMonitor/Settings.StyleCop
deleted file mode 100644
index 1590d17baa..0000000000
--- a/OpenRA.GameMonitor/Settings.StyleCop
+++ /dev/null
@@ -1,344 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRA.Lint/OpenRA.Lint.csproj b/OpenRA.Lint/OpenRA.Lint.csproj
deleted file mode 100644
index f5aef68227..0000000000
--- a/OpenRA.Lint/OpenRA.Lint.csproj
+++ /dev/null
@@ -1,87 +0,0 @@
-
-
-
- Debug
- AnyCPU
- {F9FA4D9F-2302-470A-8A07-6E37F488C124}
- Exe
- Properties
- OpenRA
- OpenRA.Lint
- 512
-
-
- 3.5
-
- publish\
- true
- Disk
- false
- Foreground
- 7
- Days
- false
- false
- true
- 0
- 1.0.0.%2a
- false
- false
- true
-
-
- true
- full
- ..\
- DEBUG;TRACE
- prompt
- x86
- false
- AllRules.ruleset
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {0DFB103F-2962-400F-8C6D-E2C28CCBA633}
- OpenRA.Game
- False
-
-
-
-
- False
- .NET Framework 3.5 SP1 Client Profile
- false
-
-
- False
- .NET Framework 3.5 SP1
- true
-
-
- False
- Windows Installer 3.1
- true
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRA.Lint/Settings.StyleCop b/OpenRA.Lint/Settings.StyleCop
deleted file mode 100644
index 2e3436170c..0000000000
--- a/OpenRA.Lint/Settings.StyleCop
+++ /dev/null
@@ -1,334 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRA.Mods.Cnc/Settings.StyleCop b/OpenRA.Mods.Cnc/Settings.StyleCop
deleted file mode 100644
index 1590d17baa..0000000000
--- a/OpenRA.Mods.Cnc/Settings.StyleCop
+++ /dev/null
@@ -1,344 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
index 9526687c40..c46f3e917c 100644
--- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
+++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj
@@ -31,14 +31,22 @@
-
- False
- ..\thirdparty\Eluant.dll
- False
-
+
+ ..\thirdparty\Eluant.dll
+ False
+
+
+ ..\thirdparty\StyleCop.CSharp.Rules.dll
+
+
+ ..\thirdparty\StyleCop.CSharp.dll
+
+
+ ..\thirdparty\StyleCop.dll
+
@@ -243,6 +251,8 @@
+
+
diff --git a/OpenRA.Mods.Common/Settings.StyleCop b/OpenRA.Mods.Common/Settings.StyleCop
deleted file mode 100644
index 1590d17baa..0000000000
--- a/OpenRA.Mods.Common/Settings.StyleCop
+++ /dev/null
@@ -1,344 +0,0 @@
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
- False
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/OpenRA.Mods.Common/UtilityCommands/CheckCodeStyle.cs b/OpenRA.Mods.Common/UtilityCommands/CheckCodeStyle.cs
new file mode 100644
index 0000000000..017c84a6f4
--- /dev/null
+++ b/OpenRA.Mods.Common/UtilityCommands/CheckCodeStyle.cs
@@ -0,0 +1,56 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
+ * This file is part of OpenRA, which is free software. It is made
+ * available to you under the terms of the GNU General Public License
+ * as published by the Free Software Foundation. For more information,
+ * see COPYING.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using OpenRA.FileSystem;
+using OpenRA.Traits;
+using StyleCop;
+
+namespace OpenRA.Mods.Common.UtilityCommands
+{
+ class CheckCodeStyle : IUtilityCommand
+ {
+ public string Name { get { return "--check-code-style"; } }
+ int violationCount;
+
+ [Desc("DIRECTORY", "Check the *.cs source code files in a directory for code style violations.")]
+ public void Run(ModData modData, string[] args)
+ {
+ var projectPath = Path.GetFullPath(args[1]);
+
+ 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);
+
+ console.OutputGenerated += OnOutputGenerated;
+ console.ViolationEncountered += OnViolationEncountered;
+ console.Start(new[] { project }, true);
+
+ if (violationCount > 0)
+ Environment.Exit(1);
+ }
+
+ void OnOutputGenerated(object sender, OutputEventArgs e)
+ {
+ Console.WriteLine(e.Output);
+ }
+
+ void OnViolationEncountered(object sender, ViolationEventArgs e)
+ {
+ violationCount++;
+ Console.WriteLine("{0}:L{1}: [{2}] {3}", e.SourceCode.Path, e.LineNumber, e.Violation.Rule.CheckId, e.Message);
+ }
+ }
+}
diff --git a/OpenRA.Lint/YamlChecker.cs b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs
similarity index 66%
rename from OpenRA.Lint/YamlChecker.cs
rename to OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs
index c8686378bb..d9f1deea25 100644
--- a/OpenRA.Lint/YamlChecker.cs
+++ b/OpenRA.Mods.Common/UtilityCommands/CheckYaml.cs
@@ -14,52 +14,43 @@ using System.Linq;
using OpenRA.FileSystem;
using OpenRA.Traits;
-namespace OpenRA.Lint
+namespace OpenRA.Mods.Common.UtilityCommands
{
- static class YamlChecker
+ class CheckYaml : IUtilityCommand
{
+ public string Name { get { return "--check-yaml"; } }
+
static int errors = 0;
// mimic Windows compiler error format
static void EmitError(string e)
{
- Console.WriteLine("OpenRA.Lint(1,1): Error: {0}", e);
+ Console.WriteLine("OpenRA.Utility(1,1): Error: {0}", e);
++errors;
}
static void EmitWarning(string e)
{
- Console.WriteLine("OpenRA.Lint(1,1): Warning: {0}", e);
+ Console.WriteLine("OpenRA.Utility(1,1): Warning: {0}", e);
}
- static int Main(string[] args)
+ [Desc("[MAPFILE]", "Check a mod or map for certain yaml errors.")]
+ public void Run(ModData modData, string[] args)
{
- if (args.Length == 0)
- {
- Console.WriteLine("Usage: OpenRA.Lint.exe MOD [MAP] [--verbose]");
- return 0;
- }
+ // HACK: The engine code assumes that Game.modData is set.
+ Game.modData = modData;
try
{
Log.AddChannel("debug", null);
Log.AddChannel("perf", null);
- var options = args.Where(a => a.StartsWith("-"));
- var mod = args.Where(a => !options.Contains(a)).First();
- var map = args.Where(a => !options.Contains(a)).Skip(1).FirstOrDefault();
- var verbose = options.Contains("-v") || options.Contains("--verbose");
-
// bind some nonfatal error handling into FieldLoader, so we don't just *explode*.
ObjectCreator.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s));
FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name));
- AppDomain.CurrentDomain.AssemblyResolve += GlobalFileSystem.ResolveAssembly;
- Game.InitializeSettings(Arguments.Empty);
- Game.modData = new ModData(mod);
-
IEnumerable