Class ParameterDefinition
- Namespace
- AsmResolver.DotNet
- Assembly
- AsmResolver.DotNet.dll
Represents a single definition for a parameter that is defined by a method in a .NET executable file.
public class ParameterDefinition : MetadataMember, IHasCustomAttribute, IHasConstant, IHasFieldMarshal, IMetadataMember, INameProvider, IModuleProvider, IOwnedCollectionElement<MethodDefinition>
- Inheritance
-
ParameterDefinition
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
A method is not required to provide parameter definitions for all its parameters that are defined by its signature. Parameter definitions only provide additional information, such as a name, attributes or a default value.
Constructors
ParameterDefinition(MetadataToken)
Initializes a new parameter definition.
protected ParameterDefinition(MetadataToken token)
Parameters
token
MetadataTokenThe token of the parameter definition.
ParameterDefinition(Utf8String?)
Creates a new parameter definition using the provided name.
public ParameterDefinition(Utf8String? name)
Parameters
name
Utf8StringThe name of the new parameter.
ParameterDefinition(ushort, Utf8String?, ParameterAttributes)
Creates a new parameter definition using the provided name and attributes.
public ParameterDefinition(ushort sequence, Utf8String? name, ParameterAttributes attributes)
Parameters
sequence
ushortThe sequence number of the new parameter.
name
Utf8StringThe name of the new parameter.
attributes
ParameterAttributesThe attributes to assign to the parameter.
Properties
Attributes
Gets or sets the attributes associated to the parameter definition.
public ParameterAttributes Attributes { get; set; }
Property Value
Constant
Gets or sets a constant that is assigned to the member.
public Constant? Constant { get; set; }
Property Value
Remarks
If this property is set to null
, the member is not assigned a constant value.
Updating this property does not update any of the attributes associated to the member.
CustomAttributes
Gets a collection of custom attributes assigned to this member.
public IList<CustomAttribute> CustomAttributes { get; }
Property Value
HasDefault
Gets or sets a value indicating whether the parameter has a default value.
public bool HasDefault { get; set; }
Property Value
Remarks
For valid .NET binaries, when Constant is not null
, this flag should be set.
However, assigning a value to this property does not automatically update the Constant
property, nor does it reflect whether Constant has a value or not.
HasFieldMarshal
Gets or sets a value indicating whether the parameter is marked as an output parameter.
public bool HasFieldMarshal { get; set; }
Property Value
Remarks
For valid .NET binaries, when MarshalDescriptor is not null
, this flag should be set.
However, assigning a value to this property does not automatically update the MarshalDescriptor
property, nor does it reflect whether MarshalDescriptor has a value or not.
IsIn
Gets or sets a value indicating whether the parameter is marked as an input parameter.
public bool IsIn { get; set; }
Property Value
IsOptional
Gets or sets a value indicating whether the parameter is marked as an optional parameter.
public bool IsOptional { get; set; }
Property Value
IsOut
Gets or sets a value indicating whether the parameter is marked as an output parameter.
public bool IsOut { get; set; }
Property Value
MarshalDescriptor
Gets or sets the description on how a specific value needs to be marshaled upon calling to or from unmanaged code via P/Invoke dispatch.
public MarshalDescriptor? MarshalDescriptor { get; set; }
Property Value
Remarks
For valid .NET binaries, when the value of this property is not null
, the HasFieldMarshal
flag should be set. However, assigning a new value to this property does not automatically update the value
of the HasFieldMarshal property.
Method
Gets the method that defines the parameter.
public MethodDefinition? Method { 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 parameter.
public Utf8String? Name { get; set; }
Property Value
Remarks
This property corresponds to the Name column in the parameter definition table.
Sequence
Gets or sets the index for which this parameter definition provides information for.
public ushort Sequence { get; set; }
Property Value
Methods
GetConstant()
Obtains the constant value assigned to the parameter definition.
protected virtual Constant? GetConstant()
Returns
- Constant
The constant.
Remarks
This method is called upon initialization of the Constant 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.
GetMarshalDescriptor()
Obtains the marshal descriptor value assigned to the parameter definition.
protected virtual MarshalDescriptor? GetMarshalDescriptor()
Returns
- MarshalDescriptor
The marshal descriptor.
Remarks
This method is called upon initialization of the MarshalDescriptor property.
GetMethod()
Obtains the method that owns the parameter.
protected virtual MethodDefinition? GetMethod()
Returns
- MethodDefinition
The name.
Remarks
This method is called upon initialization of the Method property.
GetName()
Obtains the name of the parameter.
protected virtual Utf8String? GetName()
Returns
- Utf8String
The name.
Remarks
This method is called upon initialization of the Name property.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.