Skip to content

Commit

Permalink
Update CommandLineUtils, switch to OnExecuteAsync (although async is …
Browse files Browse the repository at this point in the history
…not yet used)
  • Loading branch information
christophwille committed Jul 12, 2023
1 parent 1100d64 commit 5156a9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
6 changes: 1 addition & 5 deletions ICSharpCode.ILSpyCmd/ICSharpCode.ILSpyCmd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="3.1.0" />
<PackageReference Include="System.IO.FileSystem.Primitives" Version="4.3.0" />
<PackageReference Include="System.Runtime.Handles" Version="4.3.0" />
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.Extensions" Version="4.3.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.0.2" />
</ItemGroup>

<Target Name="ILSpyUpdateAssemblyInfo" AfterTargets="ResolveProjectReferences">
Expand Down
15 changes: 8 additions & 7 deletions ICSharpCode.ILSpyCmd/IlspyCmdProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,7 +49,7 @@ into nicely nested directories.
MemberName = nameof(DecompilerVersion))]
class ILSpyCmdProgram
{
public static int Main(string[] args) => CommandLineApplication.Execute<ILSpyCmdProgram>(args);
public static Task<int> Main(string[] args) => CommandLineApplication.ExecuteAsync<ILSpyCmdProgram>(args);

[FilesExist]
[Required]
Expand Down Expand Up @@ -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<int> OnExecuteAsync(CommandLineApplication app)
{
TextWriter output = System.Console.Out;
string outputDirectory = ResolveOutputDirectory(OutputDirectory);
Expand All @@ -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<ProjectItem>();
foreach (var file in InputAssemblyNames)
Expand All @@ -135,23 +136,23 @@ 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
{
foreach (var file in InputAssemblyNames)
{
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
{
Expand Down

0 comments on commit 5156a9d

Please sign in to comment.