Table of Contents

Class PEFile

Namespace
ICSharpCode.Decompiler.Metadata
Assembly
ICSharpCode.Decompiler.dll

PEFile is the main class the decompiler uses to represent a metadata assembly/module. Every file on disk can be loaded into a standalone PEFile instance.

A PEFile can be combined with its referenced assemblies/modules to form a type system, in that case the MetadataModule class is used instead.

public class PEFile : IDisposable, IModuleReference
Inheritance
PEFile
Implements
Inherited Members
Extension Methods

Remarks

In addition to wrapping a System.Reflection.Metadata.PEReader, this class contains a few decompiler-specific caches to allow efficiently constructing a type system from multiple PEFiles. This allows the caches to be shared across multiple decompiled type systems.

Constructors

PEFile(string, Stream, PEStreamOptions, MetadataReaderOptions)

public PEFile(string fileName, Stream stream, PEStreamOptions streamOptions = PEStreamOptions.Default, MetadataReaderOptions metadataOptions = MetadataReaderOptions.ApplyWindowsRuntimeProjections)

Parameters

fileName string
stream Stream
streamOptions PEStreamOptions
metadataOptions MetadataReaderOptions

PEFile(string, PEReader, MetadataReaderOptions)

public PEFile(string fileName, PEReader reader, MetadataReaderOptions metadataOptions = MetadataReaderOptions.ApplyWindowsRuntimeProjections)

Parameters

fileName string
reader PEReader
metadataOptions MetadataReaderOptions

PEFile(string, PEStreamOptions, MetadataReaderOptions)

public PEFile(string fileName, PEStreamOptions streamOptions = PEStreamOptions.Default, MetadataReaderOptions metadataOptions = MetadataReaderOptions.ApplyWindowsRuntimeProjections)

Parameters

fileName string
streamOptions PEStreamOptions
metadataOptions MetadataReaderOptions

Properties

AssemblyReferences

public ImmutableArray<AssemblyReference> AssemblyReferences { get; }

Property Value

ImmutableArray<AssemblyReference>

FileName

public string FileName { get; }

Property Value

string

FullName

public string FullName { get; }

Property Value

string

IsAssembly

public bool IsAssembly { get; }

Property Value

bool

Metadata

public MetadataReader Metadata { get; }

Property Value

MetadataReader

Name

public string Name { get; }

Property Value

string

Reader

public PEReader Reader { get; }

Property Value

PEReader

Resources

public ImmutableArray<Resource> Resources { get; }

Property Value

ImmutableArray<Resource>

Methods

Dispose()

public void Dispose()

GetRuntime()

public TargetRuntime GetRuntime()

Returns

TargetRuntime

GetTypeDefinition(TopLevelTypeName)

Finds the top-level-type with the specified name.

public TypeDefinitionHandle GetTypeDefinition(TopLevelTypeName typeName)

Parameters

typeName TopLevelTypeName

Returns

TypeDefinitionHandle

GetTypeForwarder(FullTypeName)

Finds the type forwarder with the specified name.

public ExportedTypeHandle GetTypeForwarder(FullTypeName typeName)

Parameters

typeName FullTypeName

Returns

ExportedTypeHandle

WithOptions(TypeSystemOptions)

public IModuleReference WithOptions(TypeSystemOptions options)

Parameters

options TypeSystemOptions

Returns

IModuleReference