diff --git a/src/CSScriptLib/src/CSScriptLib/Evaluator.CodeDom.cs b/src/CSScriptLib/src/CSScriptLib/Evaluator.CodeDom.cs index 4a33822c..781dc9b6 100644 --- a/src/CSScriptLib/src/CSScriptLib/Evaluator.CodeDom.cs +++ b/src/CSScriptLib/src/CSScriptLib/Evaluator.CodeDom.cs @@ -57,6 +57,20 @@ public class CodeDomEvaluator : EvaluatorBase, IEvaluator /// public static bool CompileOnServer = true; + /// + /// Timeout for the C# CLI compiler `csc.exe`. + /// + /// This compiler is a part of .NET SDK and it is the actual + /// tool that compiles C# code into assembly when CodeDomEvaluator is used. + /// This tool under certain circumstances has tendency to hang after even if it successfully + /// finished the compilation. Thus configurable timeout allows user to configure forcible termination + /// of the csc.exe process. + /// + /// + /// The default value is -1 (infinite). + /// + public static int CscTimeout = -1; + /// /// The low level output of the last script compilation. This member is not designed to be a /// part of script error handling. For this purpose a normal exception based mechanism the @@ -302,7 +316,7 @@ bool buildServerNotRunning() => response.GetLines() { cmd = $@"""{Globals.csc}"" {common_args.JoinBy(" ")} /out:""{assembly}"" {refs_args.JoinBy(" ")} {source_args.JoinBy(" ")}"; - result.NativeCompilerReturnValue = dotnet.Run(cmd, build_dir, x => result.Output.Add(x), x => std_err += x); + result.NativeCompilerReturnValue = dotnet.Run(cmd, build_dir, x => result.Output.Add(x), x => std_err += x, CodeDomEvaluator.CscTimeout); } } else @@ -311,7 +325,7 @@ bool buildServerNotRunning() => response.GetLines() try { - result.NativeCompilerReturnValue = Globals.csc.Run(cmd, build_dir, x => result.Output.Add(x), x => std_err += x); + result.NativeCompilerReturnValue = Globals.csc.Run(cmd, build_dir, x => result.Output.Add(x), x => std_err += x, CodeDomEvaluator.CscTimeout); } catch (Exception e) {