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, IMethodDefOrRef, ICustomAttributeType, 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
parentIMemberRefParentThe declaring member that defines the referenced member.
nameUtf8StringThe name of the referenced member.
signatureMemberSignatureThe 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
tokenMetadataTokenThe metadata token of the reference.
Fields
CustomAttributesInternal
The internal custom attribute list.
protected IList<CustomAttribute>? CustomAttributesInternal
Field Value
Remarks
This value may not be initialized. Use CustomAttributes instead.
Properties
ContextModule
Gets the module that defines the member definition or reference.
public ModuleDefinition? ContextModule { 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.
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
HasCustomAttributes
Gets a value indicating whether the member is assigned custom attributes.
public virtual bool HasCustomAttributes { get; }
Property Value
IsField
Gets a value indicating whether the referenced member is a field.
[MemberNotNullWhen(true, "Signature")]
public bool IsField { get; }
Property Value
IsMethod
Gets a value indicating whether the referenced member is a method
[MemberNotNullWhen(true, "Signature")]
public bool IsMethod { get; }
Property Value
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
importerReferenceImporterThe 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
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.
Resolve(RuntimeContext?)
Resolves the reference to a member definition.
public IMemberDefinition Resolve(RuntimeContext? context)
Parameters
contextRuntimeContext
Returns
- IMemberDefinition
The resolved member definition.
Exceptions
- ArgumentOutOfRangeException
Occurs when the member reference has an invalid signature.
ToString()
public override string ToString()
Returns
TryResolve(RuntimeContext?, out IMemberDefinition?)
Attempts to resolve the member descriptor to its definition in the provided context.
public bool TryResolve(RuntimeContext? context, out IMemberDefinition? definition)
Parameters
contextRuntimeContextThe context to assume when resolving the member.
definitionIMemberDefinitionThe resolved member definition, or
nullif resolution failed.
Returns
- bool
trueif the resolution was successful,falseotherwise.