Table of Contents

Struct MetadataToken

Namespace
AsmResolver.PE.DotNet.Metadata.Tables
Assembly
AsmResolver.PE.dll

Represents a metadata token, referencing a member using a table and a row index.

public readonly struct MetadataToken : IComparable<MetadataToken>
Implements
Inherited Members

Constructors

MetadataToken(TableIndex, uint)

Creates a new metadata token from a table index and a row index.

public MetadataToken(TableIndex table, uint rid)

Parameters

table TableIndex

The table.

rid uint

The row index.

Exceptions

ArgumentOutOfRangeException

Occurs when rid is too large.

MetadataToken(uint)

Creates a new metadata token from a raw 32 bit integer.

public MetadataToken(uint value)

Parameters

value uint

The raw metadata token.

Fields

Zero

Represents the zero metadata token, or the absence of a metadata token.

public static readonly MetadataToken Zero

Field Value

MetadataToken

Properties

Rid

Gets the row index within the table specified by Table that the metadata token references.

public uint Rid { get; }

Property Value

uint

Table

Gets the table that the metadata token references.

public TableIndex Table { get; }

Property Value

TableIndex

Methods

CompareTo(MetadataToken)

public int CompareTo(MetadataToken other)

Parameters

other MetadataToken

Returns

int

Equals(MetadataToken)

Determines whether the metadata token refers to the same member as another metadata token.

public bool Equals(MetadataToken other)

Parameters

other MetadataToken

The other metadata token.

Returns

bool

true if the token refers to the same member, false otherwise.

Equals(object?)

public override bool Equals(object? obj)

Parameters

obj object

Returns

bool

GetHashCode()

public override int GetHashCode()

Returns

int

ToInt32()

Converts the metadata token to a signed 32 bit integer.

public int ToInt32()

Returns

int

The raw metadata token.

ToString()

public override string ToString()

Returns

string

ToUInt32()

Converts the metadata token to an unsigned 32 bit integer.

public uint ToUInt32()

Returns

uint

The raw metadata token.

Operators

operator ==(MetadataToken, MetadataToken)

Determines whether two metadata tokens are considered equal. That is, both the table index and the row identifier match.

public static bool operator ==(MetadataToken a, MetadataToken b)

Parameters

a MetadataToken

The first metadata token.

b MetadataToken

The second metadata token.

Returns

bool

true if the tokens are considered equal, false otherwise.

implicit operator MetadataToken(int)

Converts a 32-bit integer to a metadata token.

public static implicit operator MetadataToken(int token)

Parameters

token int

The token to convert.

Returns

MetadataToken

The metadata token.

implicit operator MetadataToken(uint)

Converts a 32-bit unsigned integer to a metadata token.

public static implicit operator MetadataToken(uint token)

Parameters

token uint

The token to convert.

Returns

MetadataToken

The metadata token.

operator !=(MetadataToken, MetadataToken)

Determines whether two metadata tokens are not considered equal. That is, either the table index or the row identifier (or both) does not match the other.

public static bool operator !=(MetadataToken a, MetadataToken b)

Parameters

a MetadataToken

The first metadata token.

b MetadataToken

The second metadata token.

Returns

bool

true if the tokens are not considered equal, false otherwise.