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));

Review comment (suggestion):
Trailing whitespace detected at the end of this line. According to the repository's code formatting conventions, there should be no trailing whitespace.
```suggestion
        #endif
```

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));