 simplicity, Prefix and Postfix patches can be considered part of the Original and are not shown here:</p>
<pre><code class="lang-csharp" name="example">static R ReplacementMethod(T optionalThisArgument /*, ... arguments ... */ )
{
    R result = default;
    var finalized = false;
    Exception ex = null;

    // All this code is generated dynamically, which means that
    // Harmony can build it depending on
    //
    // - if there are any finalizers (otherwise, skip try-catch)
    //
    // 