Table of Contents

Class AssemblyResolverBase

Namespace
AsmResolver.DotNet
Assembly
AsmResolver.DotNet.dll

Provides a base implementation of an assembly resolver, that includes a collection of search directories to look into for probing assemblies.

public abstract class AssemblyResolverBase : IAssemblyResolver
Inheritance
AssemblyResolverBase
Implements
Derived
Inherited Members

Constructors

AssemblyResolverBase(ModuleReaderParameters)

Initializes the base of an assembly resolver.

protected AssemblyResolverBase(ModuleReaderParameters readerParameters)

Parameters

readerParameters ModuleReaderParameters

The reader parameters used for reading new resolved assemblies.

AssemblyResolverBase(IFileService)

Initializes the base of an assembly resolver.

protected AssemblyResolverBase(IFileService fileService)

Parameters

fileService IFileService

The service to use for reading files from the disk.

Properties

FileService

Gets the file service that is used for reading files from the disk.

public IFileService FileService { get; }

Property Value

IFileService

ReaderParameters

Gets the reader parameters used for reading new resolved assemblies.

public ModuleReaderParameters ReaderParameters { get; }

Property Value

ModuleReaderParameters

SearchDirectories

Gets a collection of custom search directories that are probed upon resolving a reference to an assembly.

public IList<string> SearchDirectories { get; }

Property Value

IList<string>

Methods

AddToCache(AssemblyDescriptor, AssemblyDefinition)

Adds the assembly to the cache.

public void AddToCache(AssemblyDescriptor descriptor, AssemblyDefinition definition)

Parameters

descriptor AssemblyDescriptor

The reference to the assembly.

definition AssemblyDefinition

The assembly.

ClearCache()

Clears the cache.

public void ClearCache()

HasCached(AssemblyDescriptor)

Determines whether the provided assembly descriptor was resolved before and stored in the cache.

public bool HasCached(AssemblyDescriptor descriptor)

Parameters

descriptor AssemblyDescriptor

The reference to the assembly.

Returns

bool

true if the assembly was resolved and cached, false otherwise.

LoadAssemblyFromFile(string)

Attempts to read an assembly from its file path.

protected virtual AssemblyDefinition LoadAssemblyFromFile(string path)

Parameters

path string

The path to the assembly.

Returns

AssemblyDefinition

The assembly.

ProbeDirectory(AssemblyDescriptor, string)

Probes a directory for the provided assembly.

protected static string? ProbeDirectory(AssemblyDescriptor assembly, string directory)

Parameters

assembly AssemblyDescriptor

The assembly descriptor to search.

directory string

The path to the directory to probe.

Returns

string

The path to the assembly, or null if none was found.

ProbeRuntimeDirectories(AssemblyDescriptor)

Probes all known runtime directories for the provided assembly.

protected abstract string? ProbeRuntimeDirectories(AssemblyDescriptor assembly)

Parameters

assembly AssemblyDescriptor

The assembly descriptor to search.

Returns

string

The path to the assembly, or null if none was found.

ProbeSearchDirectories(AssemblyDescriptor)

Probes all search directories in SearchDirectories for the provided assembly.

protected string? ProbeSearchDirectories(AssemblyDescriptor assembly)

Parameters

assembly AssemblyDescriptor

The assembly descriptor to search.

Returns

string

The path to the assembly, or null if none was found.

RemoveFromCache(AssemblyDescriptor)

Removes the assembly from the cache.

public bool RemoveFromCache(AssemblyDescriptor descriptor)

Parameters

descriptor AssemblyDescriptor

The reference to the assembly.

Returns

bool

true if the assembly descriptor existed in the cache and was removed successfully, false otherwise.

Resolve(AssemblyDescriptor)

Resolves a reference to an assembly.

public AssemblyDefinition? Resolve(AssemblyDescriptor assembly)

Parameters

assembly AssemblyDescriptor

The reference to the assembly.

Returns

AssemblyDefinition

The resolved assembly, or null if the resolution failed.

ResolveImpl(AssemblyDescriptor)

Resolves a new unseen reference to an assembly.

protected virtual AssemblyDefinition? ResolveImpl(AssemblyDescriptor assembly)

Parameters

assembly AssemblyDescriptor

The assembly to resolve.

Returns

AssemblyDefinition

The resolved assembly, or null if the resolution failed.

Remarks

This method should not implement caching of resolved assemblies. The caller of this method already implements this.