From 5156a9db00b8b9e2a396c313de5b92ea0f750270 Mon Sep 17 00:00:00 2001 From: Christoph Wille Date: Wed, 12 Jul 2023 14:08:40 +0200 Subject: [PATCH] Update CommandLineUtils, switch to OnExecuteAsync (although async is not yet used) --- ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj | 6 +----- ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs | 15 ++++++++------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj b/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj index 27a0ad480e..cfbb05b506 100644 --- a/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj +++ b/ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj @@ -49,11 +49,7 @@ - - - - - + diff --git a/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs b/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs index 1e46531cfc..6fe688dead 100644 --- a/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs +++ b/ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs @@ -8,6 +8,7 @@ using System.Reflection.Metadata; using System.Reflection.PortableExecutable; using System.Threading; +using System.Threading.Tasks; using ICSharpCode.Decompiler; using ICSharpCode.Decompiler.CSharp; @@ -48,7 +49,7 @@ into nicely nested directories. MemberName = nameof(DecompilerVersion))] class ILSpyCmdProgram { - public static int Main(string[] args) => CommandLineApplication.Execute(args); + public static Task Main(string[] args) => CommandLineApplication.ExecuteAsync(args); [FilesExist] [Required] @@ -106,7 +107,7 @@ class ILSpyCmdProgram [Option("--nested-directories", "Use nested directories for namespaces.", CommandOptionType.NoValue)] public bool NestedDirectories { get; } - private int OnExecute(CommandLineApplication app) + private Task OnExecuteAsync(CommandLineApplication app) { TextWriter output = System.Console.Out; string outputDirectory = ResolveOutputDirectory(OutputDirectory); @@ -124,7 +125,7 @@ private int OnExecute(CommandLineApplication app) { string projectFileName = Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(InputAssemblyNames[0]) + ".csproj"); DecompileAsProject(InputAssemblyNames[0], projectFileName); - return 0; + return Task.FromResult(0); } var projects = new List(); foreach (var file in InputAssemblyNames) @@ -135,7 +136,7 @@ private int OnExecute(CommandLineApplication app) projects.Add(new ProjectItem(projectFileName, projectId.PlatformName, projectId.Guid, projectId.TypeGuid)); } SolutionCreator.WriteSolutionFile(Path.Combine(outputDirectory, Path.GetFileNameWithoutExtension(outputDirectory) + ".sln"), projects); - return 0; + return Task.FromResult(0); } else { @@ -143,15 +144,15 @@ private int OnExecute(CommandLineApplication app) { int result = PerformPerFileAction(file); if (result != 0) - return result; + return Task.FromResult(result); } - return 0; + return Task.FromResult(0); } } catch (Exception ex) { app.Error.WriteLine(ex.ToString()); - return ProgramExitCodes.EX_SOFTWARE; + return Task.FromResult(ProgramExitCodes.EX_SOFTWARE); } finally {