oleg-st / ZstdSharp

Port of zstd compression library to c#
MIT License
217 stars 29 forks source link

Failed to create a Decompressor() on MAUI Android #14

Closed r-laf closed 1 year ago

r-laf commented 1 year ago

Hi,

I was trying to use ZstdSharp (ver 0.6.6) in a MAUI project targeting Android. The building was fine, but when I ran it, exception raised when constructing a Decompressor.

The exception was at line https://github.com/oleg-st/ZstdSharp/blob/master/src/ZstdSharp/Unsafe/ZstdCompress.cs#L2725 with the following information

System.ArrayTypeMismatchException
  Message=Attempted to access an element as a type incompatible with the array.
oleg-st commented 1 year ago

Looks like a problem with Mono which doesn't support nested arrays with function pointers.

A code with the same exception:

unsafe class Program
{
    public static delegate* managed<int>[][] Functions = {
        new delegate* managed<int>[]
        {
            &Function,
        },
    };

    public static int Function() => 42;
}
r-laf commented 1 year ago

Just wanted to ask is there a way around it with Mono?

oleg-st commented 1 year ago

I will make a workaround for this.

oleg-st commented 1 year ago

Fixed in 0.6.7

oleg-st commented 1 year ago

@zh4ui Could you check it?

r-laf commented 1 year ago

Sure, I will check it tomorrow

r-laf commented 1 year ago

Sure, I will check it tomorrow

Thanks for the update! With 0.6.7, I confirm it's now okay to do dictionary-based decompression on MAUI for Android.