From 290a44440ca3a5cce2dc53de5a6859e1ec7e1d74 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Fri, 30 Jul 2010 09:25:12 +1200 Subject: [PATCH] cnc should run 'ralint cnc' after build, not 'ralint ra'. ralint no longer allows exceptions to escape. --- OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj | 4 +-- RALint/RALint.cs | 48 +++++++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj index 43fda42138..c4e71d6bb3 100644 --- a/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj +++ b/OpenRA.Mods.Cnc/OpenRA.Mods.Cnc.csproj @@ -1,4 +1,4 @@ - + Debug @@ -87,6 +87,6 @@ mkdir "$(SolutionDir)mods/cnc/" copy "$(TargetPath)" "$(SolutionDir)mods/cnc/" cd "$(SolutionDir)" -ralint ra +ralint cnc \ No newline at end of file diff --git a/RALint/RALint.cs b/RALint/RALint.cs index 634e12b63e..4ec929db57 100644 --- a/RALint/RALint.cs +++ b/RALint/RALint.cs @@ -33,29 +33,37 @@ namespace RALint static int Main(string[] args) { - // bind some nonfatal error handling into FieldLoader, so we don't just *explode*. - Game.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s)); - FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name)); - - Game.InitializeEngineWithMods(args); - - // all the @something names which actually EXIST. - var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null) - .Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct(); - - ValidPrereqs = Rules.Info.Keys.Concat(psuedoPrereqs).ToDictionary(a => a, a => 0); - - foreach (var actorInfo in Rules.Info) - foreach (var traitInfo in actorInfo.Value.Traits.WithInterface()) - CheckTrait(actorInfo.Value, traitInfo); - - if (errors > 0) + try { - Console.WriteLine("Errors: {0}", errors); + // bind some nonfatal error handling into FieldLoader, so we don't just *explode*. + Game.MissingTypeAction = s => EmitError("Missing Type: {0}".F(s)); + FieldLoader.UnknownFieldAction = (s, f) => EmitError("FieldLoader: Missing field `{0}` on `{1}`".F(s, f.Name)); + + Game.InitializeEngineWithMods(args); + + // all the @something names which actually EXIST. + var psuedoPrereqs = Rules.Info.Values.Select(a => a.Traits.GetOrDefault()).Where(b => b != null) + .Select(b => b.AlternateName).Where(n => n != null).SelectMany(a => a).Select(a => a.ToLowerInvariant()).Distinct(); + + ValidPrereqs = Rules.Info.Keys.Concat(psuedoPrereqs).ToDictionary(a => a, a => 0); + + foreach (var actorInfo in Rules.Info) + foreach (var traitInfo in actorInfo.Value.Traits.WithInterface()) + CheckTrait(actorInfo.Value, traitInfo); + + if (errors > 0) + { + Console.WriteLine("Errors: {0}", errors); + return 1; + } + + return 0; + } + catch (Exception e) + { + Console.WriteLine("Failed with exception: {0}".F(e)); return 1; } - - return 0; } static void CheckTrait(ActorInfo actorInfo, ITraitInfo traitInfo)