Class AssemblyDescriptor
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Provides a base implementation for describing a self-describing .NET assembly hosted by a common language runtime (CLR).
public abstract class AssemblyDescriptor : MetadataMember, IHasCustomAttribute, IMetadataMember, IFullNameProvider, INameProvider, IImportable
- Inheritance
-
AssemblyDescriptor
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
AssemblyDescriptor(MetadataToken)
Initializes a new empty assembly descriptor.
protected AssemblyDescriptor(MetadataToken token)
Parameters
tokenMetadataTokenThe token of the assembly descriptor.
Fields
CustomAttributesInternal
The internal custom attribute list.
protected IList<CustomAttribute>? CustomAttributesInternal
Field Value
Remarks
This value may not be initialized. Use CustomAttributes instead.
Properties
Attributes
Gets or sets the attributes associated to the assembly.
public AssemblyAttributes Attributes { get; set; }
Property Value
Remarks
This property corresponds to the Attributes column in the assembly table.
Culture
Gets or sets the locale string of the assembly (if available).
public Utf8String? Culture { get; set; }
Property Value
Remarks
If this value is set to null, the default locale will be used
This property corresponds to the Culture column in the assembly table.
CustomAttributes
Gets a collection of custom attributes assigned to this member.
public IList<CustomAttribute> CustomAttributes { get; }
Property Value
DisableJitCompileOptimizer
Gets or sets a value indicating any just-in-time (JIT) compiler optimization is disabled for the assembly.
public bool DisableJitCompileOptimizer { get; set; }
Property Value
Remarks
This attribute originates from the DebuggableAttribute attribute.
EnableJitCompileTracking
Gets or sets a value indicating just-in-time (JIT) compiler tracking is enabled for the assembly.
public bool EnableJitCompileTracking { get; set; }
Property Value
Remarks
This attribute originates from the DebuggableAttribute attribute.
FullName
Gets the full name of the object.
public string FullName { get; }
Property Value
HasCustomAttributes
Gets a value indicating whether the member is assigned custom attributes.
public virtual bool HasCustomAttributes { get; }
Property Value
HasPublicKey
Gets or sets a value indicating whether the assembly holds the full (unhashed) public key.
public bool HasPublicKey { get; set; }
Property Value
IsRetargetable
Gets or sets a value indicating whether the assembly can be retargeted (at runtime) to an assembly from a different publisher.
public bool IsRetargetable { get; set; }
Property Value
IsWindowsRuntime
Gets or sets a value indicating whether the assembly contains Windows Runtime (WinRT) code or not.
public bool IsWindowsRuntime { get; set; }
Property Value
Name
Gets or sets the name of the assembly.
public Utf8String? Name { get; set; }
Property Value
Remarks
This property corresponds to the Name column in the assembly table.
Version
Gets or sets the version of the assembly.
public Version Version { get; set; }
Property Value
Remarks
This property corresponds to the MajorVersion, MinorVersion, BuildNumber and RevisionNumber columns in the assembly table.
Methods
ComputePublicKeyToken(byte[], AssemblyHashAlgorithm)
Computes the token of a public key using the provided hashing algorithm.
protected static byte[] ComputePublicKeyToken(byte[] publicKey, AssemblyHashAlgorithm algorithm)
Parameters
publicKeybyte[]The public key to obtain the token from.
algorithmAssemblyHashAlgorithmThe algorithm to use.
Returns
- byte[]
The public key token.
GetCulture()
Obtains the locale string of the assembly definition.
protected virtual Utf8String? GetCulture()
Returns
- Utf8String
The locale string.
Remarks
This method is called upon initializing the Culture property.
GetCustomAttributes()
Obtains the list of custom attributes assigned to the member.
protected virtual IList<CustomAttribute> GetCustomAttributes()
Returns
- IList<CustomAttribute>
The attributes
Remarks
This method is called upon initialization of the CustomAttributes property.
GetName()
Obtains the name of the assembly definition.
protected virtual Utf8String? GetName()
Returns
- Utf8String
The name.
Remarks
This method is called upon initializing the Name property.
GetPublicKeyToken()
When the application is signed with a strong name, obtains the public key token of the assembly
public abstract byte[]? GetPublicKeyToken()
Returns
- byte[]
The token.
ImportWith(ReferenceImporter)
Imports the assembly descriptor using the provided reference importer.
public abstract AssemblyReference ImportWith(ReferenceImporter importer)
Parameters
importerReferenceImporterThe importer object to use.
Returns
- AssemblyReference
The imported assembly reference.
IsCorLib(in DotNetRuntimeInfo)
Determines whether the assembly descriptor references a Common Object Runtime standard library, according to the provided host runtime.
public bool IsCorLib(in DotNetRuntimeInfo contextRuntime)
Parameters
contextRuntimeDotNetRuntimeInfoThe runtime to assume the host is running as.
Returns
- bool
trueif it is considered a corlib according to the provided runtime,falseotherwise.
IsImplementationCorLib(in DotNetRuntimeInfo)
Determines whether the assembly descriptor references a Common Object Runtime standard implementation library, according to the provided host runtime.
public bool IsImplementationCorLib(in DotNetRuntimeInfo contextRuntime)
Parameters
contextRuntimeDotNetRuntimeInfoThe runtime to assume the host is running as.
Returns
- bool
trueif it is considered a implementation corlib according to the provided runtime,falseotherwise.
IsImportedInModule(ModuleDefinition)
Determines whether the descriptor of the member is fully imported in the provided module.
public abstract 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.
IsReferenceCorLib(in DotNetRuntimeInfo)
Determines whether the assembly descriptor references a Common Object Runtime standard reference (facade) library, according to the provided host runtime.
public bool IsReferenceCorLib(in DotNetRuntimeInfo contextRuntime)
Parameters
contextRuntimeDotNetRuntimeInfoThe runtime to assume the host is running as.
Returns
- bool
trueif it is considered a facade corlib according to the provided runtime,falseotherwise.
Resolve(RuntimeContext?)
Resolves the assembly reference to its definition.
public AssemblyDefinition Resolve(RuntimeContext? context)
Parameters
contextRuntimeContext
Returns
- AssemblyDefinition
The assembly definition.
Resolve(RuntimeContext?, out AssemblyDefinition?)
Attempts to resolve the assembly reference to its definition.
public abstract 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.
ToAssemblyReference()
Constructs a new assembly reference based on the descriptor.
public AssemblyReference ToAssemblyReference()
Returns
- AssemblyReference
The reference.
ToString()
public override string ToString()
Returns
TryResolve(RuntimeContext?, out AssemblyDefinition?)
Attempts to resolve the assembly reference to its definition.
public bool TryResolve(RuntimeContext? context, out AssemblyDefinition? assembly)
Parameters
contextRuntimeContextThe context to assume when resolving the assembly.
assemblyAssemblyDefinitionThe resolved assembly, or
nullif resolution failed.
Returns
- bool
trueif the resolution succeeded,falseotherwise.