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
readerParametersModuleReaderParametersThe reader parameters used for reading new resolved assemblies.
AssemblyResolverBase(IFileService)
Initializes the base of an assembly resolver.
protected AssemblyResolverBase(IFileService fileService)
Parameters
fileServiceIFileServiceThe 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
ReaderParameters
Gets the reader parameters used for reading new resolved assemblies.
public ModuleReaderParameters ReaderParameters { get; }
Property Value
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
Methods
AddToCache(AssemblyDescriptor, AssemblyDefinition)
Adds the assembly to the cache.
public void AddToCache(AssemblyDescriptor descriptor, AssemblyDefinition definition)
Parameters
descriptorAssemblyDescriptorThe reference to the assembly.
definitionAssemblyDefinitionThe 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
descriptorAssemblyDescriptorThe reference to the assembly.
Returns
- bool
trueif the assembly was resolved and cached,falseotherwise.
LoadAssemblyFromFile(string)
Attempts to read an assembly from its file path.
protected virtual AssemblyDefinition LoadAssemblyFromFile(string path)
Parameters
pathstringThe 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
assemblyAssemblyDescriptorThe assembly descriptor to search.
directorystringThe path to the directory to probe.
Returns
- string
The path to the assembly, or
nullif none was found.
ProbeRuntimeDirectories(AssemblyDescriptor)
Probes all known runtime directories for the provided assembly.
protected abstract string? ProbeRuntimeDirectories(AssemblyDescriptor assembly)
Parameters
assemblyAssemblyDescriptorThe assembly descriptor to search.
Returns
- string
The path to the assembly, or
nullif none was found.
ProbeSearchDirectories(AssemblyDescriptor)
Probes all search directories in SearchDirectories for the provided assembly.
protected string? ProbeSearchDirectories(AssemblyDescriptor assembly)
Parameters
assemblyAssemblyDescriptorThe assembly descriptor to search.
Returns
- string
The path to the assembly, or
nullif none was found.
RemoveFromCache(AssemblyDescriptor)
Removes the assembly from the cache.
public bool RemoveFromCache(AssemblyDescriptor descriptor)
Parameters
descriptorAssemblyDescriptorThe reference to the assembly.
Returns
- bool
trueif the assembly descriptor existed in the cache and was removed successfully,falseotherwise.
Resolve(AssemblyDescriptor)
Resolves a reference to an assembly.
public AssemblyDefinition? Resolve(AssemblyDescriptor assembly)
Parameters
assemblyAssemblyDescriptorThe reference to the assembly.
Returns
- AssemblyDefinition
The resolved assembly, or
nullif the resolution failed.
ResolveImpl(AssemblyDescriptor)
Resolves a new unseen reference to an assembly.
protected virtual AssemblyDefinition? ResolveImpl(AssemblyDescriptor assembly)
Parameters
assemblyAssemblyDescriptorThe assembly to resolve.
Returns
- AssemblyDefinition
The resolved assembly, or
nullif the resolution failed.
Remarks
This method should not implement caching of resolved assemblies. The caller of this method already implements this.