Browse Source

Add missing documentation in CSharpDecompiler.

pull/1464/head
Siegfried Pammer 6 years ago
parent
commit
a23c192324
  1. 38
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

38
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -77,6 +77,9 @@ namespace ICSharpCode.Decompiler.CSharp
}; };
} }
/// <summary>
/// Returns all built-in transforms of the ILAst pipeline.
/// </summary>
public static List<IILTransform> GetILTransforms() public static List<IILTransform> GetILTransforms()
{ {
return new List<IILTransform> { return new List<IILTransform> {
@ -162,6 +165,9 @@ namespace ICSharpCode.Decompiler.CSharp
List<IAstTransform> astTransforms = GetAstTransforms(); List<IAstTransform> astTransforms = GetAstTransforms();
/// <summary>
/// Returns all built-in transforms of the C# AST pipeline.
/// </summary>
public static List<IAstTransform> GetAstTransforms() public static List<IAstTransform> GetAstTransforms()
{ {
return new List<IAstTransform> { return new List<IAstTransform> {
@ -184,8 +190,14 @@ namespace ICSharpCode.Decompiler.CSharp
}; };
} }
/// <summary>
/// Token to check for requested cancellation of the decompilation.
/// </summary>
public CancellationToken CancellationToken { get; set; } public CancellationToken CancellationToken { get; set; }
/// <summary>
/// The type system created from the main module and referenced modules.
/// </summary>
public IDecompilerTypeSystem TypeSystem => typeSystem; public IDecompilerTypeSystem TypeSystem => typeSystem;
/// <summary> /// <summary>
@ -212,21 +224,33 @@ namespace ICSharpCode.Decompiler.CSharp
get { return astTransforms; } 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) public CSharpDecompiler(string fileName, DecompilerSettings settings)
: this(CreateTypeSystemFromFile(fileName, settings), 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) public CSharpDecompiler(string fileName, IAssemblyResolver assemblyResolver, DecompilerSettings settings)
: this(LoadPEFile(fileName, settings), assemblyResolver, 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) public CSharpDecompiler(PEFile module, IAssemblyResolver assemblyResolver, DecompilerSettings settings)
: this(new DecompilerTypeSystem(module, assemblyResolver, settings), 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) public CSharpDecompiler(DecompilerTypeSystem typeSystem, DecompilerSettings settings)
{ {
this.typeSystem = typeSystem ?? throw new ArgumentNullException(nameof(typeSystem)); this.typeSystem = typeSystem ?? throw new ArgumentNullException(nameof(typeSystem));
@ -238,6 +262,12 @@ namespace ICSharpCode.Decompiler.CSharp
} }
#region MemberIsHidden #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) public static bool MemberIsHidden(Metadata.PEFile module, EntityHandle member, DecompilerSettings settings)
{ {
if (module == null || member.IsNil) if (module == null || member.IsNil)
@ -505,6 +535,9 @@ namespace ICSharpCode.Decompiler.CSharp
return syntaxTree; return syntaxTree;
} }
/// <summary>
/// Creates an <see cref="ILTransformContext"/> for the given <paramref name="function"/>.
/// </summary>
public ILTransformContext CreateILTransformContext(ILFunction function) public ILTransformContext CreateILTransformContext(ILFunction function)
{ {
var decompileRun = new DecompileRun(settings) { var decompileRun = new DecompileRun(settings) {
@ -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) public static CodeMappingInfo GetCodeMappingInfo(PEFile module, EntityHandle member)
{ {
var declaringType = member.GetDeclaringType(module.Metadata); var declaringType = member.GetDeclaringType(module.Metadata);
@ -587,7 +623,7 @@ namespace ICSharpCode.Decompiler.CSharp
switch (memberRef.Parent.Kind) { switch (memberRef.Parent.Kind) {
case HandleKind.TypeReference: case HandleKind.TypeReference:
// This should never happen in normal code, because we are looking at nested types // 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. // those should be either TypeDef or TypeSpec.
continue; continue;
case HandleKind.TypeDefinition: case HandleKind.TypeDefinition:

Loading…
Cancel
Save