The MethodDef table has the following columns:
-
RVA (a 4-byte constant)
-
ImplFlags (a 2-byte bitmask of type MethodImplAttributes, §II.23.1.11)
-
Flags (a 2-byte bitmask of type MethodAttributes, §II.23.1.10)
-
Name (an index into the String heap)
-
Signature (an index into the Blob heap)
-
ParamList (an index into the Param table). It marks the first of a contiguous run of Parameters owned by this method. The run continues to the smaller of:
-
the last row of the Param table
-
the next run of Parameters, found by inspecting the ParamList of the next row in the MethodDef table
-
Conceptually, every row in the MethodDef table is owned by one, and only one, row in the TypeDef table.
The rows in the MethodDef table result from .method directives (§II.15). The RVA column is computed when the image for the PE file is emitted and points to the COR_ILMETHOD
structure for the body of the method (§II.25.4)
[Note: If Signature is GENERIC
(0x10), the generic arguments are described in the GenericParam table (§II.22.20). end note]
This contains informative text only.
-
The MethodDef table can contain zero or more rows
-
Each row shall have one, and only one, owner row in the TypeDef table [ERROR]
-
ImplFlags shall have only those values set that are specified [ERROR]
-
Flags shall have only those values set that are specified [ERROR]
-
If Name is
.ctor
and the method is markedSpecialName
, there shall not be a row in the GenericParam table which has this MethodDef as its owner. [ERROR] -
The
MemberAccessMask
(§II.23.1.10) subfield of Flags shall contain precisely one ofCompilerControlled
,Private
,FamANDAssem
,Assem
,Family
,FamORAssem
, orPublic
[ERROR] -
The following combined bit settings in Flags are invalid [ERROR]
-
Static
|Final
-
Static
|Virtual
-
Static
|NewSlot
-
Final
|Abstract
-
Abstract
|PinvokeImpl
-
CompilerControlled
|SpecialName
-
CompilerControlled
|RTSpecialName
-
-
An abstract method shall be virtual. So, if Flags.
Abstract
= 1 then Flags.Virtual
shall also be 1 [ERROR] -
If Flags.
RTSpecialName
= 1 then Flags.SpecialName
shall also be 1 [ERROR] -
If Flags.
HasSecurity
= 1, then at least one of the following conditions shall be true: [ERROR]-
this Method owns at least row in the DeclSecurity table
-
this Method has a custom attribute called
SuppressUnmanagedCodeSecurityAttribute
-
-
If this Method owns one (or more) rows in the DeclSecurity table then Flags.
HasSecurity
shall be 1 [ERROR] -
If this Method has a custom attribute called
SuppressUnmanagedCodeSecurityAttribute
then Flags.HasSecurity
shall be 1 [ERROR] -
A Method can have a custom attribute called
DynamicSecurityMethodAttribute
, but this has no effect whatsoever upon the value of its Flags.HasSecurity
-
Name shall index a non-empty string in the String heap [ERROR]
-
Interfaces cannot have instance constructors. So, if this Method is owned by an Interface, then its Name cannot be
.ctor
[ERROR] -
The Name string shall be a valid CLS identifier (unless Flags.
RTSpecialName
is set - for example,.cctor
is valid) [CLS] -
Signature shall index a valid method signature in the Blob heap [ERROR]
-
If Flags.
CompilerControlled
= 1, then this row is ignored completely in duplicate checking -
If the owner of this method is the internally-generated type called
<Module>
, it denotes that this method is defined at module scope. [Note: In C++, the method is called global and can be referenced only within its compilation unit, from its point of declaration forwards. end note] In this case:-
Flags.
Static
shall be 1 [ERROR] -
Flags.
Abstract
shall be 0 [ERROR] -
Flags.
Virtual
shall be 0 [ERROR] -
Flags.
MemberAccessMask
subfield shall be one ofCompilerControlled
,Public
, orPrivate
[ERROR] -
module-scope methods are not allowed [CLS]
-
-
It makes no sense for ValueTypes, which have no identity, to have synchronized methods (unless they are boxed). So, if the owner of this method is a ValueType then the method cannot be synchronized. That is, ImplFlags.
Synchronized
shall be 0 [ERROR] -
There shall be no duplicate rows in the MethodDef table, based upon owner + Name + Signature (where owner is the owning row in the TypeDef table). (Note that the Signature encodes whether or not the method is generic, and for generic methods, it encodes the number of generic parameters.) (Note, however, that if Flags.
CompilerControlled
= 1, then this row is excluded from duplicate checking) [ERROR] -
There shall be no duplicate rows in the MethodDef table, based upon owner + Name + Signature, where Name fields are compared using CLS conflicting-identifierrules; also, the Type defined in the signatures shall be different. So, for example,
int i
andfloat i
would be considered CLS duplicates; also, the return type of the method is ignored (Note, however, that if Flags.CompilerControlled
= 1, this row is excluded from duplicate checking as explained above.) [CLS] -
If
Final
,NewSlot
, orStrict
are set in Flags, then Flags.Virtual
shall also be set [ERROR] -
If Flags.
PInvokeImpl
is set, then Flags.Virtual
shall be 0 [ERROR] -
If Flags.
Abstract
≠ 1 then exactly one of the following shall also be true: [ERROR]-
RVA ≠ 0
-
Flags.
PInvokeImpl
= 1 -
ImplFlags.
Runtime
= 1
-
-
If the method is
CompilerControlled
, then the RVA shall be non-zero or marked withPinvokeImpl
= 1 [ERROR] -
Signature shall have exactly one of the following managed calling conventions [ERROR]
-
DEFAULT
(0x0) -
VARARG
(0x5) -
GENERIC
(0x10)
-
-
Signature shall have the calling convention
DEFAULT
(0x0) orGENERIC
(0x10). [CLS] -
Signature: If and only if the method is not
Static
then the calling convention byte in Signature has itsHASTHIS
(0x20) bit set [ERROR] -
Signature: If the method is
static
, then theHASTHIS
(0x20) bit in the calling convention shall be 0 [ERROR] -
If
EXPLICITTHIS
(0x40) in the signature is set, thenHASTHIS
(0x20) shall also be set (note that ifEXPLICITTHIS
is set, then the code is not verifiable) [ERROR] -
The
EXPLICITTHIS
(0x40) bit can be set only in signatures for function pointers: signatures whose MethodDefSig is preceded byFNPTR
(0x1B) [ERROR] -
If RVA = 0, then either: [ERROR]
-
Flags.
Abstract
= 1, or -
ImplFlags.
Runtime
= 1, or -
Flags.
PinvokeImpl
= 1, or
-
-
If RVA ≠ 0, then: [ERROR]
-
Flags.
Abstract
shall be 0, and -
ImplFlags.
CodeTypeMask
shall have exactly one of the following values:Native
,CIL
, orRuntime
, and -
RVA shall point into the CIL code stream in this file
-
-
If Flags.
PinvokeImpl
= 1 then [ERROR]- RVA = 0 and the method owns a row in the ImplMap table
-
If Flags.
RTSpecialName
= 1 then Name shall be one of: [ERROR]-
.ctor
(an object constructor method) -
.cctor
(a class constructor method)
-
-
Conversely, if Name is any of the above special names then Flags.
RTSpecialName
shall be set [ERROR] -
If Name =
.ctor
(an object constructor method) then:-
return type in Signature shall be
ELEMENT_TYPE_VOID
(§II.23.1.16) [ERROR] -
Flags.
Static
shall be 0 [ERROR] -
Flags.
Abstract
shall be 0 [ERROR] -
Flags.
Virtual
shall be [ERROR] -
'Owner' type shall be a valid Class or ValueType (not
<Module>
and not an Interface) in the TypeDef table [ERROR] -
there can be zero or more
.ctor
s for any given 'owner'
-
-
If Name =
.cctor
(a class constructor method) then:-
the return type in Signature shall be
ELEMENT_TYPE_VOID
(§II.23.1.16) [ERROR] -
Signature shall have
DEFAULT
(0x0) for its calling convention [ERROR] -
there shall be no parameters supplied in Signature [ERROR]
-
Flags.
Static
shall be set [ERROR] -
Flags.
Virtual
shall be clear [ERROR] -
Flags.
Abstract
shall be clear [ERROR]
-
-
Among the set of methods owned by any given row in the TypeDef table there can only be 0 or 1 methods named
.cctor
[ERROR]
End informative text.