From 58ce13fd9ad6c078a097bea5c0cb01e362bb0e69 Mon Sep 17 00:00:00 2001 From: oleg-shilo Date: Thu, 19 Jan 2017 11:56:44 +1100 Subject: [PATCH] * Issue#33: Cleanup routine throws ArgumentException --- Source/Utils.cs | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/Source/Utils.cs b/Source/Utils.cs index 949b4956..363de7cd 100644 --- a/Source/Utils.cs +++ b/Source/Utils.cs @@ -283,15 +283,9 @@ public static void CleanUnusedTmpFiles(string dir, string pattern, bool verifyPi if (int.TryParse(pidValue, out pid)) { - try - { - if (Process.GetProcessById(pid) != null) - continue; //still running - } - catch - { - //GetProcessById will throw if pid is not running and Utils.FileDelete handles all unexpected - } + //Didn't use GetProcessById as it throws if pid is not running + if (Process.GetProcesses().Any(p => p.Id == pid)) + continue; //still running } } } @@ -473,12 +467,12 @@ internal static void VerbosePrint(string message, ExecuteOptions options) public static string DbgInjectionCode = DbgInjectionCodeInterface; internal static string DbgInjectionCodeInterface = @"partial class dbg { - public static bool publicOnly = false; + public static bool publicOnly = true; public static bool propsOnly = false; + public static int max_items = 25; public static int depth = 1; - public static void print(object @object){} - public static void printf(string format, params object[] args){} - public static void print(params object[] args){} + public static void printf(string format, params object[] args) { } + public static void print(object @object, params object[] args) { } }"; internal static string GetScriptedCodeDbgInjectionCode(string scriptFileName) @@ -598,7 +592,7 @@ public static string CompileResource(string file, string out_name) var input = file; var output = Path.ChangeExtension(file, ".resources"); - if(out_name != null) + if (out_name != null) output = Path.Combine(Path.GetDirectoryName(file), out_name); string css_dir_res_gen = Environment.ExpandEnvironmentVariables(@"%CSSCRIPT_DIR%\lib\resgen.exe"); @@ -631,11 +625,11 @@ public static string CompileResource(string file, string out_name) catch (Exception e) { if (!File.Exists(css_dir_res_gen)) - throw new ApplicationException("Cannot invoke " + resgen_exe + ": " + e.Message + - "\nEnsure resgen.exe is in the %CSSCRIPT_DIR%\\lib or "+ - "its location is in the system PATH. Alternatively you "+ - "can specify the direct location of resgen.exe via "+ - "CSS_RESGEN environment variable."); + throw new ApplicationException("Cannot invoke " + resgen_exe + ": " + e.Message + + "\nEnsure resgen.exe is in the %CSSCRIPT_DIR%\\lib or " + + "its location is in the system PATH. Alternatively you " + + "can specify the direct location of resgen.exe via " + + "CSS_RESGEN environment variable."); } if (error.Length > 0)