lerc icon indicating copy to clipboard operation
lerc copied to clipboard

New implementation for C#.

Open halmaia opened this issue 1 year ago • 1 comments

A new implementation based on spans was created for both encoding and decoding to support various scenarios beyond the standard .NET array. This allows for the use of various sources, such as arrays, ArrayPools, and natively or externally allocated memory. For both the Encode and Decode functions, pre-allocated buffers can be provided to avoid allocation. If buffers were not provided, an uninitialized array will be allocated by the GC, which will then be filled by the LercAPI. Due to design limitations in .NET's Span, the largest buffer size is either int.MaxValue or 2147483591 (the maximum length of an array). While pinned or aligned buffers are certainly welcome, it is important to note that they are not strictly necessary. Encoding were implemented as generics, decoding as Span but can be casted painlessly to any Span with the help of MemoryMarshall.Cast. The implementation of P/Invoke marshalling has been replaced with the use of safe and unsafe pointers. Enums and structs with convenience methods were added.

halmaia avatar Feb 21 '24 17:02 halmaia

If I've done something wrong, feel free to let me know!

halmaia avatar Feb 21 '24 17:02 halmaia

@halmaia Thank you for this contribution! I haven't done anything in C# for years, so I can't give you any ratings on it. Let's see what others say. I hope you are ready and willing to maintain your C# code in case there are bugs or any other issues.

tmaurer3 avatar Mar 01 '24 22:03 tmaurer3