From da070ac400f4348cef5d0d5b95ae0a8ee8544693 Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Mon, 26 Feb 2024 12:51:27 +0800 Subject: [PATCH 1/2] fix: 0 for OK; any 1 for exception --- src/Neo.Compiler.CSharp/Program.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Neo.Compiler.CSharp/Program.cs b/src/Neo.Compiler.CSharp/Program.cs index 8738fd365..355c4dd6c 100644 --- a/src/Neo.Compiler.CSharp/Program.cs +++ b/src/Neo.Compiler.CSharp/Program.cs @@ -138,7 +138,22 @@ private static int ProcessSources(Options options, string folder, string[] sourc private static int ProcessOutputs(Options options, string folder, List contexts) { - return contexts.Select(p => ProcessOutput(options, folder, p)).Any(p => p != 1) ? 0 : 1; + int result = 0; + List exceptions = new(); + foreach (CompilationContext context in contexts) + try + { + if (ProcessOutput(options, folder, context) != 0) + result = 1; + } + catch (Exception e) + { + result = 1; + exceptions.Add(e); + } + foreach (Exception e in exceptions) + Console.Error.WriteLine(e.ToString()); + return result; } private static int ProcessOutput(Options options, string folder, CompilationContext context) From 69dc50fcf2380dc125f0e34fdaea395fe85456fa Mon Sep 17 00:00:00 2001 From: Hecate2 <2474101468@qq.com> Date: Mon, 26 Feb 2024 12:52:45 +0800 Subject: [PATCH 2/2] do not include .cs in bin/sc --- src/Neo.Compiler.CSharp/CompilationEngine.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Neo.Compiler.CSharp/CompilationEngine.cs b/src/Neo.Compiler.CSharp/CompilationEngine.cs index 9d46344a6..951a57b5e 100644 --- a/src/Neo.Compiler.CSharp/CompilationEngine.cs +++ b/src/Neo.Compiler.CSharp/CompilationEngine.cs @@ -172,8 +172,9 @@ public Compilation GetCompilation(string csproj) { string folder = Path.GetDirectoryName(csproj)!; string obj = Path.Combine(folder, "obj"); + string binSc = Path.Combine(Path.Combine(folder, "bin"), "sc"); HashSet sourceFiles = Directory.EnumerateFiles(folder, "*.cs", SearchOption.AllDirectories) - .Where(p => !p.StartsWith(obj)) + .Where(p => !p.StartsWith(obj) && !p.StartsWith(binSc)) .GroupBy(Path.GetFileName) .Select(g => g.First()) .ToHashSet(StringComparer.OrdinalIgnoreCase);