Class AssemblyReference
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Represents a reference to an external .NET assembly, hosted by a common language runtime (CLR).
public class AssemblyReference : AssemblyDescriptor, IResolutionScope, IModuleProvider, IOwnedCollectionElement<ModuleDefinition>, IImplementation, IImportable, IFullNameProvider, INameProvider, IHasCustomAttribute, IMetadataMember
- Inheritance
-
AssemblyReference
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
AssemblyReference(AssemblyDescriptor)
Creates a new assembly reference, and copies over all properties of another assembly descriptor.
public AssemblyReference(AssemblyDescriptor descriptor)
Parameters
descriptorAssemblyDescriptorThe assembly to base the reference on.
AssemblyReference(MetadataToken)
Initializes a new assembly reference.
protected AssemblyReference(MetadataToken token)
Parameters
tokenMetadataTokenThe token of the assembly reference.
AssemblyReference(Utf8String?, Version)
Creates a new assembly reference.
public AssemblyReference(Utf8String? name, Version version)
Parameters
nameUtf8StringThe name of the assembly.
versionVersionThe version of the assembly.
AssemblyReference(Utf8String?, Version, bool, byte[]?)
Creates a new assembly reference.
public AssemblyReference(Utf8String? name, Version version, bool publicKey, byte[]? publicKeyOrToken)
Parameters
nameUtf8StringThe name of the assembly.
versionVersionThe version of the assembly.
publicKeyboolIndicates the key provided by
publicKeyOrTokenis the full, unhashed public key used to verify the authenticity of the assembly.publicKeyOrTokenbyte[]Indicates the public key or token (depending on
publicKey), used to verify the authenticity of the assembly.
Properties
ContextModule
Gets the module that defines the member definition or reference.
public ModuleDefinition? ContextModule { get; }
Property Value
Remarks
For member references, this does not obtain the module definition that the member is defined in. Rather, it obtains the module definition that references this reference.
HashValue
Gets or sets the hash value of the assembly reference.
public byte[]? HashValue { get; set; }
Property Value
- byte[]
PublicKeyOrToken
Gets or sets the (token of the) public key of the assembly to use for verification of a signature.
public byte[]? PublicKeyOrToken { get; set; }
Property Value
- byte[]
Remarks
If this value is set to null, no public key will be assigned.
When HasPublicKey is set to true, this value contains the full
unhashed public key that was used to sign the assembly. This property does not automatically update the
HasPublicKey property.
This property corresponds to the Culture column in the assembly definition table.
Methods
GetHashValue()
Obtains the hash value of the assembly reference.
protected virtual byte[]? GetHashValue()
Returns
- byte[]
The hash value.
Remarks
This method is called upon initializing the HashValue property.
GetPublicKeyOrToken()
Obtains the public key or token of the assembly reference.
protected virtual byte[]? GetPublicKeyOrToken()
Returns
- byte[]
The public key or token.
Remarks
This method is called upon initializing the PublicKeyOrToken property.
GetPublicKeyToken()
When the application is signed with a strong name, obtains the public key token of the assembly
public override byte[]? GetPublicKeyToken()
Returns
- byte[]
The token.
ImportWith(ReferenceImporter)
Imports the assembly descriptor using the provided reference importer.
public override AssemblyReference ImportWith(ReferenceImporter importer)
Parameters
importerReferenceImporterThe importer object to use.
Returns
- AssemblyReference
The imported assembly reference.
IsImportedInModule(ModuleDefinition)
Determines whether the descriptor of the member is fully imported in the provided module.
public override bool IsImportedInModule(ModuleDefinition module)
Parameters
moduleModuleDefinitionThe module that is supposed to import the member.
Returns
- bool
trueif the descriptor of the member is fully imported by the module,falseotherwise.
Remarks
This method verifies all references in the descriptor of the member only. It does not verify any additional data or contents (such as a method body) associated to the member.
Resolve(RuntimeContext?, out AssemblyDefinition?)
Attempts to resolve the assembly reference to its definition.
public override ResolutionStatus Resolve(RuntimeContext? context, out AssemblyDefinition? assembly)
Parameters
contextRuntimeContextThe context to assume when resolving the assembly.
assemblyAssemblyDefinitionThe resolved assembly, or
nullif resolution failed.
Returns
- ResolutionStatus
A value describing the success or failure status of the assembly resolution.