Repository: dotnet/runtime
File: src/coreclr/dlls/mscoree/exports.cpp (C++)

Code before:
        else if (strcmp(propertyKeys[propertyIndex], HOST_PROPERTY_PINVOKE_OVERRIDE) == 0)
        {
            // If host provides a PInvoke override (typically in a single-file bundle),
            // the override callback is passed in as the value of "PINVOKE_OVERRIDE" property (encoded as a string).
            // The function in HOST_RUNTIME_CONTRACT is given priority over this property,
            // so we only set the p/invoke override if it has not already been set.
            if (*pinvokeOverride == nullptr)
                *pinvokeOverride = (PInvokeOverrideFn*)u16_strtoui64(propertyValuesW[propertyIndex], nullptr, 0);
        }
        else if (strcmp(propertyKeys[propertyIndex], HOST_PROPERTY_RUNTIME_CONTRACT) == 0)
        {
            // Host contract is passed in as the value of HOST_RUNTIME_CONTRACT property (encoded as a string).
            host_runtime_contract* hostContractLocal = (host_runtime_contract*)u16_strtoui64(propertyValuesW[propertyIndex], nullptr, 0);
            *hostContract = hostContractLocal;

            // Functions in HOST_RUNTIME_CONTRACT have priority over the individual properties
            // for callbacks, so we set them as long as the contract has a non-null function.
            if (hostContractLocal->bundle_probe != nullptr)
                *bundleProbe = hostContractLocal->bundle_probe;

            if (hostContractLocal->pinvoke_override != nullptr)
                *pinvokeOverride = hostContractLocal->pinvoke_override;
        }
        else if (strcmp(propertyKeys[propertyIndex], HOST_PROPERTY_CRASH_CHAINING) == 0)
        {
            // Enable crash chaining - generate crash dump before invoking previously registered signal handler.
            // This must be processed before PAL initialization.
            if (enableCrashChaining != nullptr)
            {
                *enableCrashChaining = (u16_strcmp(propertyValuesW[propertyIndex], W("1")) == 0 ||
                                        u16_strcmp(propertyValuesW[propertyIndex], W("true")) == 0);
            }
        }
    }

    *propertyKeysWRef = propertyKeysW;
    *propertyValuesWRef = propertyValuesW;
}

coreclr_error_writer_callback_fn g_errorWriter = nullptr;

//
// Set callback for writing error logging
//
// Parameters:
//  errorWriter             - callback that will be called for each line of the error info
//                          - passing in NULL removes a callback that was previously set
//
// Returns:
//  S_OK
//

Review comment (bug):
I know Mono uses "crash chaining" to describe this. Is it a good name to describe this behavior?

cc @elinor-fung New hosting property

Code after:
        {
            // If host provides a PInvoke override (typically in a single-file bundle),
            // the override callback is passed in as the value of "PINVOKE_OVERRIDE" property (encoded as a string).
            // The function in HOST_RUNTIME_CONTRACT is given priority over this property,
            // so we only set the p/invoke override if it has not already been set.
            if (*pinvokeOverride == nullptr)
                *pinvokeOverride = (PInvokeOverrideFn*)u16_strtoui64(propertyValuesW[propertyIndex], nullptr, 0);
        }
        else if (strcmp(propertyKeys[propertyIndex], HOST_PROPERTY_RUNTIME_CONTRACT) == 0)
        {
            // Host contract is passed in as the value of HOST_RUNTIME_CONTRACT property (encoded as a string).
            host_runtime_contract* hostContractLocal = (host_runtime_contract*)u16_strtoui64(propertyValuesW[propertyIndex], nullptr, 0);
            *hostContract = hostContractLocal;

            // Functions in HOST_RUNTIME_CONTRACT have priority over the individual properties
            // for callbacks, so we set them as long as the contract has a non-null function.
            if (hostContractLocal->bundle_probe != nullptr)
                *bundleProbe = hostContractLocal->bundle_probe;

            if (hostContractLocal->pinvoke_override != nullptr)
                *pinvokeOverride = hostContractLocal->pinvoke_override;
        }
    }

    *propertyKeysWRef = propertyKeysW;
    *propertyValuesWRef = propertyValuesW;
}

coreclr_error_writer_callback_fn g_errorWriter = nullptr;

//
// Set callback for writing error logging
//
// Parameters:
//  errorWriter             - callback that will be called for each line of the error info
//                          - passing in NULL removes a callback that was previously set
//
// Returns:
//  S_OK
//
extern "C"
DLLEXPORT
int coreclr_set_error_writer(coreclr_error_writer_callback_fn error_writer)
{
    g_errorWriter = error_writer;
    return S_OK;
}

#ifdef FEATURE_GDBJIT
GetInfoForMethodDelegate getInfoForMethodDelegate = NULL;
extern "C" int coreclr_create_delegate(void*, unsigned int, const char*, const char*, const char*, void**);