public static HandleRef <T> Allocate <T>(string propertySetterName, string?propertyResetName = null)
            where T : struct
        {
            var value = new HandleRef <T>(propertyResetName);

            try
            {
                WebAssemblyRuntime.InvokeJSUnmarshalled(propertySetterName, value.Handle);
            }
            catch (Exception e)
            {
                try
                {
                    value.Dispose();
                }
                // If the allocation failed, the dispose will most likely also fail,
                // but we want to propagate the real exception of the allocation!
                catch (Exception) { }

                if (_logger.IsEnabled(LogLevel.Error))
                {
                    _logger.Debug($"Failed Allocate {propertySetterName}/{value.Type}: {e}");
                }

                throw;
            }

            return(value);
        }