@ -77,6 +77,9 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -77,6 +77,9 @@ namespace ICSharpCode.Decompiler.CSharp
} ;
}
/// <summary>
/// Returns all built-in transforms of the ILAst pipeline.
/// </summary>
public static List < IILTransform > GetILTransforms ( )
{
return new List < IILTransform > {
@ -162,6 +165,9 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -162,6 +165,9 @@ namespace ICSharpCode.Decompiler.CSharp
List < IAstTransform > astTransforms = GetAstTransforms ( ) ;
/// <summary>
/// Returns all built-in transforms of the C# AST pipeline.
/// </summary>
public static List < IAstTransform > GetAstTransforms ( )
{
return new List < IAstTransform > {
@ -184,8 +190,14 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -184,8 +190,14 @@ namespace ICSharpCode.Decompiler.CSharp
} ;
}
/// <summary>
/// Token to check for requested cancellation of the decompilation.
/// </summary>
public CancellationToken CancellationToken { get ; set ; }
/// <summary>
/// The type system created from the main module and referenced modules.
/// </summary>
public IDecompilerTypeSystem TypeSystem = > typeSystem ;
/// <summary>
@ -212,21 +224,33 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -212,21 +224,33 @@ namespace ICSharpCode.Decompiler.CSharp
get { return astTransforms ; }
}
/// <summary>
/// Creates a new <see cref="CSharpDecompiler"/> instance from the given <paramref name="fileName"/> using the given <paramref name="settings"/>.
/// </summary>
public CSharpDecompiler ( string fileName , DecompilerSettings settings )
: this ( CreateTypeSystemFromFile ( fileName , settings ) , settings )
{
}
/// <summary>
/// Creates a new <see cref="CSharpDecompiler"/> instance from the given <paramref name="fileName"/> using the given <paramref name="assemblyResolver"/> and <paramref name="settings"/>.
/// </summary>
public CSharpDecompiler ( string fileName , IAssemblyResolver assemblyResolver , DecompilerSettings settings )
: this ( LoadPEFile ( fileName , settings ) , assemblyResolver , settings )
{
}
/// <summary>
/// Creates a new <see cref="CSharpDecompiler"/> instance from the given <paramref name="module"/> using the given <paramref name="assemblyResolver"/> and <paramref name="settings"/>.
/// </summary>
public CSharpDecompiler ( PEFile module , IAssemblyResolver assemblyResolver , DecompilerSettings settings )
: this ( new DecompilerTypeSystem ( module , assemblyResolver , settings ) , settings )
{
}
/// <summary>
/// Creates a new <see cref="CSharpDecompiler"/> instance from the given <paramref name="typeSystem"/> and the given <paramref name="settings"/>.
/// </summary>
public CSharpDecompiler ( DecompilerTypeSystem typeSystem , DecompilerSettings settings )
{
this . typeSystem = typeSystem ? ? throw new ArgumentNullException ( nameof ( typeSystem ) ) ;
@ -238,6 +262,12 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -238,6 +262,12 @@ namespace ICSharpCode.Decompiler.CSharp
}
#region MemberIsHidden
/// <summary>
/// Determines whether a <paramref name="member"/> should be hidden from the decompiled code. This is used to exclude compiler-generated code that is handled by transforms from the output.
/// </summary>
/// <param name="module">The module containing the member.</param>
/// <param name="member">The metadata token/handle of the member. Can be a TypeDef, MethodDef or FieldDef.</param>
/// <param name="settings">THe settings used to determine whether code should be hidden. E.g. if async methods are not transformed, async state machines are included in the decompiled code.</param>
public static bool MemberIsHidden ( Metadata . PEFile module , EntityHandle member , DecompilerSettings settings )
{
if ( module = = null | | member . IsNil )
@ -505,6 +535,9 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -505,6 +535,9 @@ namespace ICSharpCode.Decompiler.CSharp
return syntaxTree ;
}
/// <summary>
/// Creates an <see cref="ILTransformContext"/> for the given <paramref name="function"/>.
/// </summary>
public ILTransformContext CreateILTransformContext ( ILFunction function )
{
var decompileRun = new DecompileRun ( settings ) {
@ -518,6 +551,9 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -518,6 +551,9 @@ namespace ICSharpCode.Decompiler.CSharp
} ;
}
/// <summary>
/// Determines the "code-mappings" for a given TypeDef or MethodDef. See <see cref="CodeMappingInfo"/> for more information.
/// </summary>
public static CodeMappingInfo GetCodeMappingInfo ( PEFile module , EntityHandle member )
{
var declaringType = member . GetDeclaringType ( module . Metadata ) ;
@ -587,7 +623,7 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -587,7 +623,7 @@ namespace ICSharpCode.Decompiler.CSharp
switch ( memberRef . Parent . Kind ) {
case HandleKind . TypeReference :
// This should never happen in normal code, because we are looking at nested types
// If it's not a nested type, it can't be a reference to the statem machine anyway, and
// If it's not a nested type, it can't be a reference to the state machine anyway, and
// those should be either TypeDef or TypeSpec.
continue ;
case HandleKind . TypeDefinition :