Skip to content
Permalink
Browse files

Add LanguageVersion, RemoveDeadCode and RemoveDeadStores options to p…

…owershell cmdlet.
  • Loading branch information...
siegfriedpammer committed Oct 2, 2019
1 parent 7f873b8 commit dc4dcc508253d8b6cfd5a84a0337c36e528c059b
Showing with 13 additions and 2 deletions.
  1. +13 −2 ICSharpCode.Decompiler.PowerShell/GetDecompilerCmdlet.cs
@@ -15,13 +15,24 @@ public class GetDecompilerCmdlet : PSCmdlet
[ValidateNotNullOrEmpty]
public string LiteralPath { get; set; }

[Parameter(HelpMessage = "C# Language version to be used by the decompiler")]
public LanguageVersion LanguageVersion { get; set; } = LanguageVersion.Latest;

[Parameter(HelpMessage = "Remove dead stores")]
public bool RemoveDeadStores { get; set; }

[Parameter(HelpMessage = "Remove dead code")]
public bool RemoveDeadCode { get; set; }

protected override void ProcessRecord()
{
string path = GetUnresolvedProviderPathFromPSPath(LiteralPath);

try {
var decompiler = new CSharpDecompiler(path, new DecompilerSettings() {
ThrowOnAssemblyResolveErrors = false
var decompiler = new CSharpDecompiler(path, new DecompilerSettings(LanguageVersion) {
ThrowOnAssemblyResolveErrors = false,
RemoveDeadCode = RemoveDeadCode,
RemoveDeadStores = RemoveDeadStores
});
WriteObject(decompiler);

0 comments on commit dc4dcc5

Please sign in to comment.
You can’t perform that action at this time.