Table of Contents

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

token MetadataToken

The token of the assembly descriptor.

Properties

Attributes

Gets or sets the attributes associated to the assembly.

public AssemblyAttributes Attributes { get; set; }

Property Value

AssemblyAttributes

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

Utf8String

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

IList<CustomAttribute>

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

bool

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

bool

Remarks

This attribute originates from the DebuggableAttribute attribute.

FullName

Gets the full name of the object.

public string FullName { get; }

Property Value

string

HasPublicKey

Gets or sets a value indicating whether the assembly holds the full (unhashed) public key.

public bool HasPublicKey { get; set; }

Property Value

bool

IsCorLib

Gets a value indicating whether the assembly descriptor references a Common Object Runtime standard library.

public abstract bool IsCorLib { get; }

Property Value

bool

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

bool

IsWindowsRuntime

Gets or sets a value indicating whether the assembly contains Windows Runtime (WinRT) code or not.

public bool IsWindowsRuntime { get; set; }

Property Value

bool

Name

Gets or sets the name of the assembly.

public Utf8String? Name { get; set; }

Property Value

Utf8String

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

Version

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

publicKey byte[]

The public key to obtain the token from.

algorithm AssemblyHashAlgorithm

The 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

importer ReferenceImporter

The 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 abstract bool IsImportedInModule(ModuleDefinition module)

Parameters

module ModuleDefinition

The module that is supposed to import the member.

Returns

bool

true if the descriptor of the member is fully imported by the module, false otherwise.

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()

Resolves the reference to the assembly to an assembly definition.

public abstract AssemblyDefinition? Resolve()

Returns

AssemblyDefinition

The assembly definition, or null if the resolution failed.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.