public unsafe void ToJS(Exception?value)
        {
            if (value == null)
            {
                slot.Type = MarshalerType.None;
            }
            else
            {
                Exception cpy = value;
                if (cpy is AggregateException ae && ae.InnerExceptions.Count == 1)
                {
                    cpy = ae.InnerExceptions[0];
                }

                var jse = cpy as JSException;
                if (jse != null && jse.jsException != null)
                {
                    // this is JSException roundtrip
                    if (jse.jsException.IsDisposed)
                    {
                        throw new ObjectDisposedException(nameof(value));
                    }
                    slot.Type     = MarshalerType.JSException;
                    slot.JSHandle = jse.jsException.JSHandle;
                }
                else
                {
                    ToJS(cpy.Message);
                    slot.Type     = MarshalerType.Exception;
                    slot.GCHandle = JavaScriptExports.GetJSOwnedObjectGCHandleRef(cpy);
                }
            }
        }
        public unsafe void ToManaged(out Exception?value)
        {
            if (slot.Type == MarshalerType.None)
            {
                value = null;
                return;
            }
            if (slot.Type == MarshalerType.Exception)
            {
                // this is managed exception round-trip
#pragma warning disable CS8600 // Converting null literal or possible null value to non-nullable type.
                value = (Exception)((GCHandle)slot.GCHandle).Target;
#pragma warning restore CS8600 // Converting null literal or possible null value to non-nullable type.
                return;
            }

            JSObject?jsException = null;
            if (slot.JSHandle != IntPtr.Zero)
            {
                // this is JSException round-trip
                jsException = JavaScriptExports.CreateCSOwnedProxy(slot.JSHandle);
            }

            string?message;
            ToManaged(out message);

            value = new JSException(message !, jsException);
        }
 public unsafe void ToManaged(out JSObject?value)
 {
     if (slot.Type == MarshalerType.None)
     {
         value = null;
         return;
     }
     value = JavaScriptExports.CreateCSOwnedProxy(slot.JSHandle);
 }