forked from icsharpcode/ILSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetDecompiledTypesCmdlet.cs
41 lines (36 loc) · 1.11 KB
/
GetDecompiledTypesCmdlet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Automation;
using System.Text;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.TypeSystem;
namespace ICSharpCode.Decompiler.PowerShell
{
[Cmdlet(VerbsCommon.Get, "DecompiledTypes")]
[OutputType(typeof(ITypeDefinition[]))]
public class GetDecompiledTypesCmdlet : PSCmdlet
{
[Parameter(Position = 0, Mandatory = true)]
public CSharpDecompiler Decompiler { get; set; }
[Parameter(Mandatory = true)]
public string[] Types { get; set; }
protected override void ProcessRecord()
{
HashSet<TypeKind> kinds = TypesParser.ParseSelection(Types);
try {
List<ITypeDefinition> output = new List<ITypeDefinition>();
foreach (var type in Decompiler.TypeSystem.MainModule.TypeDefinitions) {
if (!kinds.Contains(type.Kind))
continue;
output.Add(type);
}
WriteObject(output.ToArray());
} catch (Exception e) {
WriteVerbose(e.ToString());
WriteError(new ErrorRecord(e, ErrorIds.DecompilationFailed, ErrorCategory.OperationStopped, null));
}
}
}
}