add 1.6 support and restore 1.5 compatibility

This commit is contained in:
localavaster
2026-04-07 03:34:45 -06:00
parent 418aad61f2
commit 5a3f6c1cc8
15 changed files with 197 additions and 57 deletions
+25
View File
@@ -0,0 +1,25 @@
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace FisheryLib;
internal static class SpanCompatExtensions
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe ref T DangerousGetPinnableReference<T>(this Span<T> span)
{
if (span.Length == 0)
return ref Unsafe.AsRef<T>((void*)1);
return ref span[0];
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe ref T DangerousGetPinnableReference<T>(this ReadOnlySpan<T> span)
{
if (span.Length == 0)
return ref Unsafe.AsRef<T>((void*)1);
return ref Unsafe.AsRef(in MemoryMarshal.GetReference(span));
}
}