internal static bool IsBlittable(Type elementType)
        {
            return(_isBlittableCache.GetOrAdd(elementType, _ =>
            {
                if (!elementType.IsValueType)
                {
                    return false;
                }

                if (!TypeFields.IsPrimitive(elementType))
                {
                    return false;
                }

                try
                {
                    WriteArrayOfValuesMethod1.MakeGenericMethod(elementType);
                    return true;
                }
                catch
                {
                    return false;
                }
            }));
        }
 private static Expression WriteArrayOfBlittableValues(ParameterExpression output, Expression actualSource,
                                                       ParameterExpression stream, int dimensions, Type elementType, int elementSize)
 {
     return(dimensions switch
     {
         1 => Expression.Call(output, WriteArrayOfValuesMethod1.MakeGenericMethod(elementType),
                              actualSource,
                              Expression.Constant(elementSize)),
         2 => Expression.Call(output, WriteArrayOfValuesMethod2.MakeGenericMethod(elementType),
                              actualSource,
                              Expression.Constant(elementSize)),
         _ => throw new InvalidOperationException($"Blitting multidimensional array with {dimensions} dimensions is not supported"),
     });