Table of Contents

Class SerializedModuleDefinition

Namespace
AsmResolver.DotNet.Serialized
Assembly
AsmResolver.DotNet.dll

Represents a lazily initialized implementation of ModuleDefinition that is read from a .NET metadata image.

public class SerializedModuleDefinition : ModuleDefinition, IResolutionScope, INameProvider, IModuleProvider, IImportable, IHasCustomAttribute, IMetadataMember, IOwnedCollectionElement<AssemblyDefinition>
Inheritance
SerializedModuleDefinition
Implements
Inherited Members
Extension Methods

Constructors

SerializedModuleDefinition(PEImage, ModuleReaderParameters)

Interprets a PE image as a .NET module.

public SerializedModuleDefinition(PEImage peImage, ModuleReaderParameters readerParameters)

Parameters

peImage PEImage

The image to interpret as a .NET module.

readerParameters ModuleReaderParameters

The parameters to use while reading the module.

Properties

DotNetDirectory

Gets the underlying object providing access to the data directory containing .NET metadata (if available).

public override DotNetDirectory DotNetDirectory { get; }

Property Value

DotNetDirectory

Remarks

When this property is null, the module is a new module that is not yet assembled.

ReaderContext

Gets the reading context that is used for reading the contents of the module.

public ModuleReaderContext ReaderContext { get; }

Property Value

ModuleReaderContext

Methods

EnumerateTableMembers(TableIndex)

Enumerates all metadata members stored in the module.

public override IEnumerable<IMetadataMember> EnumerateTableMembers(TableIndex tableIndex)

Parameters

tableIndex TableIndex

The table to enumerate the members for.

Returns

IEnumerable<IMetadataMember>

The members.

Remarks

The return value of this method does not update when new members are added or imported into the module. This method only serves as a way to easily get all the member references that were imported during the last compilation or assembly process. This method can also only enumerate members in a table for which there is an explicit IMetadataMember implementation available, and will return an empty collection for tables that do not have one.

GetAssemblyReferences()

Obtains the list of references to .NET assemblies that the module uses.

protected override IList<AssemblyReference> GetAssemblyReferences()

Returns

IList<AssemblyReference>

The references to the assemblies..

Remarks

This method is called upon initialization of the AssemblyReferences property.

GetCustomAttributes()

Obtains the list of custom attributes assigned to the member.

protected override IList<CustomAttribute> GetCustomAttributes()

Returns

IList<CustomAttribute>

The attributes

Remarks

This method is called upon initialization of the CustomAttributes property.

GetDebugData()

Obtains the native debug data directory of the underlying PE image (if available).

protected override IList<DebugDataEntry> GetDebugData()

Returns

IList<DebugDataEntry>

The debug directory.

Remarks

This method is called upon initialization of the DebugData property.

GetEncBaseId()

Obtains the edit-and-continue base identifier of the module definition.

protected override Guid GetEncBaseId()

Returns

Guid

The identifier.

Remarks

This method is called upon initialization of the EncBaseId property.

GetEncId()

Obtains the edit-and-continue identifier of the module definition.

protected override Guid GetEncId()

Returns

Guid

The identifier.

Remarks

This method is called upon initialization of the EncId property.

GetExportedTypes()

Obtains the list of types that are redirected to another external module.

protected override IList<ExportedType> GetExportedTypes()

Returns

IList<ExportedType>

The exported types.

Remarks

This method is called upon initialization of the ExportedTypes property.

GetFileReferences()

Obtains the list of references to external files that the module uses.

protected override IList<FileReference> GetFileReferences()

Returns

IList<FileReference>

The references to the files.

Remarks

This method is called upon initialization of the FileReferences property.

GetIndexEncoder(CodedIndex)

Obtains an object that can be used to decode coded indices to metadata tokens.

public override IndexEncoder GetIndexEncoder(CodedIndex codedIndex)

Parameters

codedIndex CodedIndex

The type of indices to get the encoder for.

Returns

IndexEncoder

The index encoder.

Exceptions

InvalidOperationException

Occurs when the module does not support index encoders.

GetManagedEntryPoint()

Obtains the managed entry point of this module.

protected override IManagedEntryPoint? GetManagedEntryPoint()

Returns

IManagedEntryPoint

The entry point.

Remarks

This method is called upon initialization of the ManagedEntryPoint property.

GetModuleReferences()

Obtains the list of references to external modules that the module uses.

protected override IList<ModuleReference> GetModuleReferences()

Returns

IList<ModuleReference>

The references to the modules.

Remarks

This method is called upon initialization of the ModuleReferences property.

GetMvid()

Obtains the MVID of the module definition.

protected override Guid GetMvid()

Returns

Guid

The MVID.

Remarks

This method is called upon initialization of the Mvid property.

GetName()

Obtains the name of the module definition.

protected override Utf8String? GetName()

Returns

Utf8String

The name.

Remarks

This method is called upon initialization of the Name property.

GetNativeResources()

Obtains the native win32 resources directory of the underlying PE image (if available).

protected override ResourceDirectory? GetNativeResources()

Returns

ResourceDirectory

The resources directory.

Remarks

This method is called upon initialization of the NativeResourceDirectory property.

GetResources()

Obtains the list of resources stored in the module.

protected override IList<ManifestResource> GetResources()

Returns

IList<ManifestResource>

The resources.

Remarks

This method is called upon initialization of the Resources property.

GetRuntimeVersion()

Obtains the version string of the runtime.

protected override string GetRuntimeVersion()

Returns

string

The runtime version.

Remarks

This method is called upon initialization of the RuntimeVersion property.

GetTopLevelTypes()

Obtains the list of top-level types the module defines.

protected override IList<TypeDefinition> GetTopLevelTypes()

Returns

IList<TypeDefinition>

The types.

Remarks

This method is called upon initialization of the TopLevelTypes property.

LookupMember(MetadataToken)

Looks up a member by its metadata token.

public override IMetadataMember LookupMember(MetadataToken token)

Parameters

token MetadataToken

The token of the member to look up.

Returns

IMetadataMember

The member.

Exceptions

InvalidOperationException

Occurs when the module does not support looking up members by its token.

NotSupportedException

Occurs when a metadata token indexes a table that cannot be converted to a metadata member.

LookupString(MetadataToken)

Looks up a user string by its string token.

public override string LookupString(MetadataToken token)

Parameters

token MetadataToken

The token of the string to look up.

Returns

string

The member.

Exceptions

InvalidOperationException

Occurs when the module does not support looking up string by its token.

ArgumentOutOfRangeException

Occurs when a metadata token indexes an invalid string.

TryLookupMember(MetadataToken, out IMetadataMember?)

Attempts to look up a member by its metadata token.

public override bool TryLookupMember(MetadataToken token, out IMetadataMember? member)

Parameters

token MetadataToken

The token of the member to look up.

member IMetadataMember

The member, or null if the lookup failed.

Returns

bool

true if the member was successfully looked up, false otherwise.

TryLookupString(MetadataToken, out string?)

Attempts to look up a user string by its metadata token.

public override bool TryLookupString(MetadataToken token, out string? value)

Parameters

token MetadataToken

The token of the member to lookup.

value string

The string, or null if the lookup failed.

Returns

bool

true if the string was successfully looked up, false otherwise.