Repository: dotnet/runtime
File: src/coreclr/vm/method.hpp (C++)

Code before:

class HostCodeHeap;
class LCGMethodResolver;
typedef DPTR(LCGMethodResolver)       PTR_LCGMethodResolver;
class ILStubResolver;
typedef DPTR(ILStubResolver)          PTR_ILStubResolver;
class DynamicResolver;
typedef DPTR(DynamicResolver)         PTR_DynamicResolver;

class DynamicMethodDesc : public StoredSigMethodDesc
{
    friend class ILStubCache;
    friend class DynamicMethodTable;

protected:
    PTR_CUTF8           m_pszMethodName;
    PTR_DynamicResolver m_pResolver;

public:

#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
    // Cached InterpreterPrecode instance for dynamic methods to avoid repeated allocations.
    DPTR(struct InterpreterPrecode) m_interpreterPrecode;
#endif

    // RuntimeTypeSystem cDAC contract depends on the values of StubPInvokeVarArg and StubCLRToCOMInterop.
    enum ILStubType : DWORD
    {
        StubNotSet = 0,
        StubPInvoke,
        StubPInvokeDelegate,
        StubPInvokeCalli,
        StubPInvokeVarArg,
        StubReversePInvoke,
        StubCLRToCOMInterop,
        StubCOMToCLRInterop,
        StubStructMarshalInterop,
        StubArrayOp,
        StubMulticastDelegate,
        StubWrapperDelegate,
        StubUnboxingIL,
        StubInstantiating,
        StubTailCallStoreArgs,
        StubTailCallCallTarget,

        StubVirtualStaticMethodDispatch,
        StubDelegateShuffleThunk,

        StubDelegateInvokeMethod,

        StubAsyncResume,

Review comment (suggestion):
This enum has fragile definition. If somebody deletes or moves e.g. `StubPInvokeDelegate`, the values of StubPInvokeVarArg and StubCLRToCOMInterop are going to shift, but it will be easy to miss that. We should make sure that all enum values that cDAC depends on are explicit.

Code after:

class HostCodeHeap;
class LCGMethodResolver;
typedef DPTR(LCGMethodResolver)       PTR_LCGMethodResolver;
class ILStubResolver;
typedef DPTR(ILStubResolver)          PTR_ILStubResolver;
class DynamicResolver;
typedef DPTR(DynamicResolver)         PTR_DynamicResolver;

class DynamicMethodDesc : public StoredSigMethodDesc
{
    friend class ILStubCache;
    friend class DynamicMethodTable;

protected:
    PTR_CUTF8           m_pszMethodName;
    PTR_DynamicResolver m_pResolver;

public:

#if defined(FEATURE_INTERPRETER) && !defined(FEATURE_PORTABLE_ENTRYPOINTS)
    // Cached InterpreterPrecode instance for dynamic methods to avoid repeated allocations.
    DPTR(struct InterpreterPrecode) m_interpreterPrecode;
#endif

    // [cDAC] [RuntimeTypeSystem]: Contract depends on the values of StubPInvokeVarArg and StubCLRToCOMInterop.
    enum ILStubType : DWORD
    {
        StubNotSet = 0,
        StubPInvoke = 1,
        StubPInvokeDelegate = 2,
        StubPInvokeCalli = 3,
        StubPInvokeVarArg = 4,
        StubReversePInvoke = 5,
        StubCLRToCOMInterop = 6,
        StubCOMToCLRInterop = 7,
        StubStructMarshalInterop = 8,
        StubArrayOp = 9,
        StubMulticastDelegate = 10,
        StubWrapperDelegate = 11,
        StubUnboxingIL = 12,
        StubInstantiating = 13,
        StubTailCallStoreArgs = 14,
        StubTailCallCallTarget = 15,

        StubVirtualStaticMethodDispatch = 16,
        StubDelegateShuffleThunk = 17,

        StubDelegateInvokeMethod = 18,

        StubAsyncResume = 19,