Class MemberReference
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Represents a reference to a method or a field in an (external) .NET assembly.
public class MemberReference : MetadataMember, ICustomAttributeType, IMethodDefOrRef, IMethodDescriptor, IHasCustomAttribute, IFieldDescriptor, IMemberDescriptor, IFullNameProvider, INameProvider, IModuleProvider, IImportable, IMetadataMember
- Inheritance
-
MemberReference
- Implements
- Derived
- Inherited Members
- Extension Methods
Constructors
MemberReference(IMemberRefParent?, Utf8String?, MemberSignature?)
Creates a new reference to a member in an (external) .NET assembly.
public MemberReference(IMemberRefParent? parent, Utf8String? name, MemberSignature? signature)
Parameters
parent
IMemberRefParentThe declaring member that defines the referenced member.
name
Utf8StringThe name of the referenced member.
signature
MemberSignatureThe signature of the referenced member. This dictates whether the referenced member is a field or a method.
MemberReference(MetadataToken)
Initializes a new member reference.
protected MemberReference(MetadataToken token)
Parameters
token
MetadataTokenThe metadata token of the reference.
Properties
CustomAttributes
Gets a collection of custom attributes assigned to this member.
public IList<CustomAttribute> CustomAttributes { get; }
Property Value
DeclaringType
Gets the type that declares the referenced member, if available.
public ITypeDefOrRef? DeclaringType { get; }
Property Value
FullName
Gets the full name of the object.
public string FullName { get; }
Property Value
IsField
Gets a value indicating whether the referenced member is a field.
public bool IsField { get; }
Property Value
IsMethod
Gets a value indicating whether the referenced member is a method
public bool IsMethod { get; }
Property Value
Module
Gets the module that defines the member definition or reference.
public ModuleDefinition? Module { 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.
Name
Gets or sets the name of the referenced member.
public Utf8String? Name { get; set; }
Property Value
Remarks
This property corresponds to the Name column in the member reference table.
Parent
Gets or sets the member that declares the referenced member.
public IMemberRefParent? Parent { get; set; }
Property Value
Signature
Gets or sets the signature of the referenced member.
public CallingConventionSignature? Signature { get; set; }
Property Value
Remarks
This property dictates whether the referenced member is a field or a method.
Methods
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 member reference.
protected virtual Utf8String? GetName()
Returns
- Utf8String
The name.
Remarks
This method is called upon initialization of the Name property.
GetParent()
Obtains the parent of the member reference.
protected virtual IMemberRefParent? GetParent()
Returns
- IMemberRefParent
The parent
Remarks
This method is called upon initialization of the Parent property.
GetSignature()
Obtains the signature of the member reference.
protected virtual CallingConventionSignature? GetSignature()
Returns
- CallingConventionSignature
The signature
Remarks
This method is called upon initialization of the Signature property.
ImportWith(ReferenceImporter)
Imports the member using the provided reference importer object.
public MemberReference ImportWith(ReferenceImporter importer)
Parameters
importer
ReferenceImporterThe reference importer to use for importing the object.
Returns
- MemberReference
The imported member.
IsImportedInModule(ModuleDefinition)
Determines whether the descriptor of the member is fully imported in the provided module.
public bool IsImportedInModule(ModuleDefinition module)
Parameters
module
ModuleDefinitionThe 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 a member definition.
public IMemberDefinition? Resolve()
Returns
- IMemberDefinition
The resolved member definition, or
null
if the member could not be resolved.
Remarks
This method can only be invoked if the reference was added to a module.
Exceptions
- ArgumentOutOfRangeException
Occurs when the member reference has an invalid signature.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.