Table of Contents

Class CustomAttributeSignature

Namespace
AsmResolver.DotNet.Signatures
Assembly
AsmResolver.DotNet.dll

Represents the blob signature of a custom attribute, containing the arguments that are passed onto the attribute constructor.

public class CustomAttributeSignature : ExtendableBlobSignature
Inheritance
CustomAttributeSignature
Derived
Inherited Members

Constructors

CustomAttributeSignature()

Creates a new empty custom attribute signature.

public CustomAttributeSignature()

CustomAttributeSignature(params CustomAttributeArgument[])

Creates a new custom attribute signature with the provided fixed arguments.

public CustomAttributeSignature(params CustomAttributeArgument[] fixedArguments)

Parameters

fixedArguments CustomAttributeArgument[]

CustomAttributeSignature(IEnumerable<CustomAttributeArgument>)

Creates a new custom attribute signature with the provided fixed arguments.

public CustomAttributeSignature(IEnumerable<CustomAttributeArgument> fixedArguments)

Parameters

fixedArguments IEnumerable<CustomAttributeArgument>

CustomAttributeSignature(IEnumerable<CustomAttributeArgument>, IEnumerable<CustomAttributeNamedArgument>)

Creates a new custom attribute signature with the provided fixed and named arguments.

public CustomAttributeSignature(IEnumerable<CustomAttributeArgument> fixedArguments, IEnumerable<CustomAttributeNamedArgument> namedArguments)

Parameters

fixedArguments IEnumerable<CustomAttributeArgument>
namedArguments IEnumerable<CustomAttributeNamedArgument>

Fields

CustomAttributeSignaturePrologue

The header value of every custom attribute signature.

protected const ushort CustomAttributeSignaturePrologue = 1

Field Value

ushort

Properties

FixedArguments

Gets a collection of fixed arguments that are passed onto the constructor of the attribute.

public IList<CustomAttributeArgument> FixedArguments { get; }

Property Value

IList<CustomAttributeArgument>

IsInitialized

Gets a value indicating whether the FixedArguments and NamedArguments collections are initialized or not.

protected bool IsInitialized { get; }

Property Value

bool

NamedArguments

Gets a collection of values that are assigned to fields and/or members of the attribute class.

public IList<CustomAttributeNamedArgument> NamedArguments { get; }

Property Value

IList<CustomAttributeNamedArgument>

Methods

EnsureIsInitialized()

Ensures that the FixedArguments and NamedArguments are initialized.

protected void EnsureIsInitialized()

FromReader(in BlobReaderContext, ICustomAttributeType, in BinaryStreamReader)

Reads a single custom attribute signature from the input stream.

public static CustomAttributeSignature FromReader(in BlobReaderContext context, ICustomAttributeType ctor, in BinaryStreamReader reader)

Parameters

context BlobReaderContext

The blob reader context.

ctor ICustomAttributeType

The constructor that was called.

reader BinaryStreamReader

The input stream.

Returns

CustomAttributeSignature

The signature.

Exceptions

FormatException

Occurs when the input stream does not point to a valid signature.

Initialize(IList<CustomAttributeArgument>, IList<CustomAttributeNamedArgument>)

Initializes the argument collections of the signature.

protected virtual void Initialize(IList<CustomAttributeArgument> fixedArguments, IList<CustomAttributeNamedArgument> namedArguments)

Parameters

fixedArguments IList<CustomAttributeArgument>

The collection that will receive the fixed arguments.

namedArguments IList<CustomAttributeNamedArgument>

The collection that will receive the named arguments.

IsCompatibleWith(ICustomAttributeType)

Validates whether the signature is compatible with the provided attribute constructor.

public bool IsCompatibleWith(ICustomAttributeType constructor)

Parameters

constructor ICustomAttributeType

The constructor to validate against.

Returns

bool

true if the constructor is compatible, false otherwise.

IsCompatibleWith(ICustomAttributeType, IErrorListener)

Validates whether the signature is compatible with the provided attribute constructor.

public virtual bool IsCompatibleWith(ICustomAttributeType constructor, IErrorListener listener)

Parameters

constructor ICustomAttributeType

The constructor to validate against.

listener IErrorListener

The object responsible for reporting any errors during the validation of the signature.

Returns

bool

true if the constructor is compatible, false otherwise.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

WriteContents(in BlobSerializationContext)

Serializes the blob (without extra data) to an output stream.

protected override void WriteContents(in BlobSerializationContext context)

Parameters

context BlobSerializationContext