.NET Decompiler with support for PDB generation, ReadyToRun, Metadata (&more) - cross-platform!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

43 lines
1.4 KiB

using System;
using System.Collections.Generic;
using System.IO;
using System.Management.Automation;
using System.Text;
using ICSharpCode.Decompiler.CSharp;
namespace ICSharpCode.Decompiler.PowerShell
{
[Cmdlet(VerbsCommon.Get, "DecompiledProject")]
[OutputType(typeof(string))]
public class GetDecompiledProjectCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true)]
public CSharpDecompiler Decompiler { get; set; }
[Parameter(Position = 1, Mandatory = true)]
[Alias("PSPath", "OutputPath")]
[ValidateNotNullOrEmpty]
public string LiteralPath { get; set; }
protected override void ProcessRecord()
{
string path = GetUnresolvedProviderPathFromPSPath(LiteralPath);
if (!Directory.Exists(path))
{
WriteObject("Destination directory must exist prior to decompilation");
return;
}
try
{
WholeProjectDecompiler decompiler = new WholeProjectDecompiler();
decompiler.DecompileProject(Decompiler.TypeSystem.MainModule.PEFile, path);
WriteObject("Decompilation finished");
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
}
}
}
}