Repository: dotnet/runtime
File: src/coreclr/vm/codeversion.cpp (C++)

Code before:
    if (!pMethod->IsVersionable())
    {
        _ASSERTE(!"This method doesn't support versioning but was requested to be versioned.");
        return E_FAIL;
    }

    HRESULT hr = S_OK;
    PCODE pCode = nativeCodeVersion.IsNull() ? (PCODE)NULL : nativeCodeVersion.GetNativeCode();
    EX_TRY
    {
        if (pCode == (PCODE)NULL)
        {
            LOG((LF_TIEREDCOMPILATION, LL_INFO100, "CVM::PublishNativeCodeVersion pMethod=%p - Resetting\n", pMethod));
            pMethod->ResetCodeEntryPoint();
        }
        else
        {
            LOG((LF_TIEREDCOMPILATION, LL_INFO100, "CVM::PublishNativeCodeVersion pMethod=%p - Set to ver=%u\n",
                pMethod,
                nativeCodeVersion.GetVersionId()));

        #ifdef FEATURE_INTERPRETER
            // When we hit the Precode that should fixup any issues with an unset interpreter code pointer. This is notably most important in ReJIT scenarios
            pMethod->ClearInterpreterCodePointer();
        #endif        
        #ifdef FEATURE_TIERED_COMPILATION
            bool wasSet = CallCountingManager::SetCodeEntryPoint(nativeCodeVersion, pCode, false, nullptr);
            _ASSERTE(wasSet);
        #else
            pMethod->SetCodeEntryPoint(pCode);
        #endif
        }
    }
    EX_CATCH_HRESULT(hr);
    return hr;
}

// static
HRESULT CodeVersionManager::EnumerateClosedMethodDescs(
    MethodDesc* pMD,
    CDynArray<MethodDesc*> * pClosedMethodDescs,
    CDynArray<CodePublishError> * pUnsupportedMethodErrors)
{
    CONTRACTL
    {
        NOTHROW;
        GC_NOTRIGGER;
        MODE_PREEMPTIVE;
        CAN_TAKE_LOCK;
        PRECONDITION(CheckPointer(pMD, NULL_OK));
        PRECONDITION(CheckPointer(pClosedMethodDescs));

Review comment (suggestion):
The indentation of the preprocessor directives is inconsistent with the surrounding code. The '#ifdef' and '#endif' directives should be aligned at column 0 (no indentation), following the standard C/C++ convention and the pattern used elsewhere in this file.
```suggestion
#ifdef FEATURE_INTERPRETER
            // When we hit the Precode that should fixup any issues with an unset interpreter code pointer. This is notably most important in ReJIT scenarios
            pMethod->ClearInterpreterCodePointer();
#endif
#ifdef FEATURE_TIERED_COMPILATION
```

Code after:
    if (!pMethod->IsVersionable())
    {
        _ASSERTE(!"This method doesn't support versioning but was requested to be versioned.");
        return E_FAIL;
    }

    HRESULT hr = S_OK;
    PCODE pCode = nativeCodeVersion.IsNull() ? (PCODE)NULL : nativeCodeVersion.GetNativeCode();
    EX_TRY
    {
        if (pCode == (PCODE)NULL)
        {
            LOG((LF_TIEREDCOMPILATION, LL_INFO100, "CVM::PublishNativeCodeVersion pMethod=%p - Resetting\n", pMethod));
            pMethod->ResetCodeEntryPoint();
        }
        else
        {
            LOG((LF_TIEREDCOMPILATION, LL_INFO100, "CVM::PublishNativeCodeVersion pMethod=%p - Set to ver=%u\n",
                pMethod,
                nativeCodeVersion.GetVersionId()));

#ifdef FEATURE_INTERPRETER
            // When we hit the Precode that should fixup any issues with an unset interpreter code pointer. This is notably most important in ReJIT scenarios
            pMethod->ClearInterpreterCodePointer();
#endif
#ifdef FEATURE_TIERED_COMPILATION
            bool wasSet = CallCountingManager::SetCodeEntryPoint(nativeCodeVersion, pCode, false, nullptr);
            _ASSERTE(wasSet);
        #else
            pMethod->SetCodeEntryPoint(pCode);
        #endif
        }
    }
    EX_CATCH_HRESULT(hr);
    return hr;
}

// static
HRESULT CodeVersionManager::EnumerateClosedMethodDescs(
    MethodDesc* pMD,
    CDynArray<MethodDesc*> * pClosedMethodDescs,
    CDynArray<CodePublishError> * pUnsupportedMethodErrors)
{
    CONTRACTL
    {
        NOTHROW;
        GC_NOTRIGGER;
        MODE_PREEMPTIVE;
        CAN_TAKE_LOCK;
        PRECONDITION(CheckPointer(pMD, NULL_OK));
        PRECONDITION(CheckPointer(pClosedMethodDescs));