Decompiled source of Raylib CsLo v4.2.91
Microsoft.Toolkit.HighPerformance.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Buffers; using System.CodeDom.Compiler; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Drawing; using System.IO; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis; using Microsoft.Toolkit.HighPerformance.Buffers; using Microsoft.Toolkit.HighPerformance.Buffers.Internals; using Microsoft.Toolkit.HighPerformance.Buffers.Internals.Interfaces; using Microsoft.Toolkit.HighPerformance.Buffers.Views; using Microsoft.Toolkit.HighPerformance.Enumerables; using Microsoft.Toolkit.HighPerformance.Helpers; using Microsoft.Toolkit.HighPerformance.Helpers.Internals; using Microsoft.Toolkit.HighPerformance.Memory.Internals; using Microsoft.Toolkit.HighPerformance.Memory.Views; using Microsoft.Toolkit.HighPerformance.Streams; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("7.1.2.1")] [assembly: AssemblyInformationalVersion("7.1.2+da6d7d3f6c")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")] [assembly: AssemblyMetadata("CommitHash", "da6d7d3f6ca9914dbe86d7d394e9a4abef25c9b6")] [assembly: AssemblyCompany(".NET Foundation")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("(c) .NET Foundation and Contributors. All rights reserved.")] [assembly: AssemblyDescription("\r\n This package includes high performance .NET Standard helpers such as:\r\n - Memory2D<T> and Span2D<T>: two types providing fast and allocation-free abstraction over 2D memory areas.\r\n - ArrayPoolBufferWriter<T>: an IBufferWriter<T> implementation using pooled arrays, which also supports IMemoryOwner<T>.\r\n - MemoryBufferWriter<T>: an IBufferWriter<T>: implementation that can wrap external Memory<T>: instances.\r\n - MemoryOwner<T>: an IMemoryOwner<T> implementation with an embedded length and a fast Span<T> accessor.\r\n - SpanOwner<T>: a stack-only type with the ability to rent a buffer of a specified length and getting a Span<T> from it.\r\n - StringPool: a configurable pool for string instances that be used to minimize allocations when creating multiple strings from char buffers.\r\n - String, array, Memory<T>, Span<T> extensions and more, all focused on high performance.\r\n - HashCode<T>: a SIMD-enabled extension of HashCode to quickly process sequences of values.\r\n - BitHelper: a class with helper methods to perform bit operations on numeric types.\r\n - ParallelHelper: helpers to work with parallel code in a highly optimized manner.\r\n - Box<T>: a type mapping boxed value types and exposing some utility and high performance methods.\r\n - Ref<T>: a stack-only struct that can store a reference to a value of a specified type.\r\n - NullableRef<T>: a stack-only struct similar to Ref<T>, which also supports nullable references.\r\n ")] [assembly: AssemblyProduct("Windows Community Toolkit")] [assembly: AssemblyTitle("Microsoft.Toolkit.HighPerformance")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/CommunityToolkit/WindowsCommunityToolkit")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("7.1.0.0")] [module: UnverifiableCode] [module: SkipLocalsInit] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } [GeneratedCode("Nerdbank.GitVersioning.Tasks", "3.3.37.35081")] [ExcludeFromCodeCoverage] internal static class ThisAssembly { internal const string AssemblyVersion = "7.1.0.0"; internal const string AssemblyFileVersion = "7.1.2.1"; internal const string AssemblyInformationalVersion = "7.1.2+da6d7d3f6c"; internal const string AssemblyName = "Microsoft.Toolkit.HighPerformance"; internal const string AssemblyTitle = "Microsoft.Toolkit.HighPerformance"; internal const string AssemblyConfiguration = "Release"; internal const string GitCommitId = "da6d7d3f6ca9914dbe86d7d394e9a4abef25c9b6"; internal const string PublicKey = "002400000480000094000000060200000024000052534131000400000100010041753af735ae6140c9508567666c51c6ab929806adb0d210694b30ab142a060237bc741f9682e7d8d4310364b4bba4ee89cc9d3d5ce7e5583587e8ea44dca09977996582875e71fb54fa7b170798d853d5d8010b07219633bdb761d01ac924da44576d6180cdceae537973982bb461c541541d58417a3794e34f45e6f2d129e2"; internal const string PublicKeyToken = "4aff67a105548ee2"; internal const bool IsPublicRelease = true; internal const bool IsPrerelease = false; internal static readonly DateTime GitCommitDate = new DateTime(637728688180000000L, DateTimeKind.Utc); internal const string RootNamespace = "Microsoft.Toolkit.HighPerformance"; } namespace Microsoft.Toolkit.HighPerformance { [DebuggerDisplay("{ToString(),raw}")] public sealed class Box<T> where T : struct { private Box() { throw new InvalidOperationException("The Microsoft.Toolkit.HighPerformance.Box<T> constructor should never be used"); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Box<T> GetFrom(object obj) { if (obj.GetType() != typeof(T)) { ThrowInvalidCastExceptionForGetFrom(); } return Unsafe.As<Box<T>>(obj); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Box<T> DangerousGetFrom(object obj) { return Unsafe.As<Box<T>>(obj); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryGetFrom(object obj, [NotNullWhen(true)] out Box<T>? box) { if (obj.GetType() == typeof(T)) { box = Unsafe.As<Box<T>>(obj); return true; } box = null; return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator T(Box<T> box) { return (T)box; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator Box<T>(T value) { return Unsafe.As<Box<T>>(value); } public override string ToString() { return this.GetReference().ToString(); } public override bool Equals(object? obj) { return object.Equals(this, obj); } public override int GetHashCode() { return this.GetReference().GetHashCode(); } private static void ThrowInvalidCastExceptionForGetFrom() { throw new InvalidCastException($"Can't cast the input object to the type Box<{typeof(T)}>"); } } public static class BoxExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T GetReference<T>(this Box<T> box) where T : struct { return ref Unsafe.Unbox<T>(box); } } public static class ArrayExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReference<T>(this T[] array) { IntPtr arrayDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayDataByteOffset<T>(); return ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, arrayDataByteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this T[] array, int i) { IntPtr arrayDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayDataByteOffset<T>(); return ref Unsafe.Add(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, arrayDataByteOffset), (nint)(uint)i); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Count<T>(this T[] array, T value) where T : IEquatable<T> { ref T r = ref array.DangerousGetReference(); nint arrayNativeLength = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayNativeLength(array); nint num = SpanHelper.Count(ref r, arrayNativeLength, value); if ((nuint)num > (nuint)2147483647u) { ThrowOverflowException(); } return (int)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SpanEnumerable<T> Enumerate<T>(this T[] array) { return new SpanEnumerable<T>(array); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SpanTokenizer<T> Tokenize<T>(this T[] array, T separator) where T : IEquatable<T> { return new SpanTokenizer<T>(array, separator); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetDjb2HashCode<T>(this T[] array) where T : notnull { ref T r = ref array.DangerousGetReference(); nint arrayNativeLength = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayNativeLength(array); return SpanHelper.GetDjb2HashCode(ref r, arrayNativeLength); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsCovariant<T>(this T[] array) { if (default(T) == null) { return array.GetType() != typeof(T[]); } return false; } private static void ThrowOverflowException() { throw new OverflowException(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReference<T>(this T[,] array) { IntPtr array2DDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray2DDataByteOffset<T>(); return ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, array2DDataByteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this T[,] array, int i, int j) { int length = array.GetLength(1); nint elementOffset = (nint)(uint)i * (nint)(uint)length + (nint)(uint)j; IntPtr array2DDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray2DDataByteOffset<T>(); return ref Unsafe.Add(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, array2DDataByteOffset), elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static RefEnumerable<T> GetRow<T>(this T[,] array, int row) { if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } int length = array.GetLength(0); if ((uint)row >= (uint)length) { ThrowArgumentOutOfRangeExceptionForRow(); } int length2 = array.GetLength(1); return new RefEnumerable<T>(ref array.DangerousGetReferenceAt(row, 0), length2, 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static RefEnumerable<T> GetColumn<T>(this T[,] array, int column) { if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } int length = array.GetLength(1); if ((uint)column >= (uint)length) { ThrowArgumentOutOfRangeExceptionForColumn(); } int length2 = array.GetLength(0); return new RefEnumerable<T>(ref array.DangerousGetReferenceAt(0, column), length2, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span2D<T> AsSpan2D<T>(this T[,]? array) { return new Span2D<T>(array); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span2D<T> AsSpan2D<T>(this T[,]? array, int row, int column, int height, int width) { return new Span2D<T>(array, row, column, height, width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory2D<T> AsMemory2D<T>(this T[,]? array) { return new Memory2D<T>(array); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory2D<T> AsMemory2D<T>(this T[,]? array, int row, int column, int height, int width) { return new Memory2D<T>(array, row, column, height, width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> GetRowSpan<T>(this T[,] array, int row) { if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } if ((uint)row >= (uint)array.GetLength(0)) { ThrowArgumentOutOfRangeExceptionForRow(); } return MemoryMarshal.CreateSpan(ref array.DangerousGetReferenceAt(row, 0), array.GetLength(1)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory<T> GetRowMemory<T>(this T[,] array, int row) { if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } if ((uint)row >= (uint)array.GetLength(0)) { ThrowArgumentOutOfRangeExceptionForRow(); } IntPtr offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(row, 0)); return new RawObjectMemoryManager<T>(array, offset, array.GetLength(1)).Memory; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory<T> AsMemory<T>(this T[,]? array) { if (array == null) { return default(Memory<T>); } if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } IntPtr array2DDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray2DDataByteOffset<T>(); int length = array.Length; return new RawObjectMemoryManager<T>(array, array2DDataByteOffset, length).Memory; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this T[,]? array) { if (array == null) { return default(Span<T>); } if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } ref T reference = ref array.DangerousGetReference(); int length = array.Length; return MemoryMarshal.CreateSpan(ref reference, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Count<T>(this T[,] array, T value) where T : IEquatable<T> { ref T r = ref array.DangerousGetReference(); nint arrayNativeLength = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayNativeLength(array); nint num = SpanHelper.Count(ref r, arrayNativeLength, value); if ((nuint)num > (nuint)2147483647u) { ThrowOverflowException(); } return (int)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetDjb2HashCode<T>(this T[,] array) where T : notnull { ref T r = ref array.DangerousGetReference(); nint arrayNativeLength = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayNativeLength(array); return SpanHelper.GetDjb2HashCode(ref r, arrayNativeLength); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsCovariant<T>(this T[,] array) { if (default(T) == null) { return array.GetType() != typeof(T[,]); } return false; } private static void ThrowArrayTypeMismatchException() { throw new ArrayTypeMismatchException("The given array doesn't match the specified type T"); } private static void ThrowArgumentOutOfRangeExceptionForRow() { throw new ArgumentOutOfRangeException("row"); } private static void ThrowArgumentOutOfRangeExceptionForColumn() { throw new ArgumentOutOfRangeException("column"); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReference<T>(this T[,,] array) { IntPtr array3DDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray3DDataByteOffset<T>(); return ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, array3DDataByteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this T[,,] array, int i, int j, int k) { int length = array.GetLength(1); int length2 = array.GetLength(2); nint elementOffset = (nint)(uint)i * (nint)(uint)length * (nint)(uint)length2 + (nint)(uint)j * (nint)(uint)length2 + (nint)(uint)k; IntPtr array3DDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray3DDataByteOffset<T>(); return ref Unsafe.Add(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, array3DDataByteOffset), elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory<T> AsMemory<T>(this T[,,]? array) { if (array == null) { return default(Memory<T>); } if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } IntPtr array3DDataByteOffset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray3DDataByteOffset<T>(); int length = array.Length; return new RawObjectMemoryManager<T>(array, array3DDataByteOffset, length).Memory; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this T[,,]? array) { if (array == null) { return default(Span<T>); } if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } ref T reference = ref array.DangerousGetReference(); int length = array.Length; return MemoryMarshal.CreateSpan(ref reference, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<T> AsSpan<T>(this T[,,] array, int depth) { if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } if ((uint)depth >= (uint)array.GetLength(0)) { ThrowArgumentOutOfRangeExceptionForDepth(); } ref T reference = ref array.DangerousGetReferenceAt(depth, 0, 0); int length = checked(array.GetLength(1) * array.GetLength(2)); return MemoryMarshal.CreateSpan(ref reference, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory<T> AsMemory<T>(this T[,,] array, int depth) { if (array.IsCovariant()) { ThrowArrayTypeMismatchException(); } if ((uint)depth >= (uint)array.GetLength(0)) { ThrowArgumentOutOfRangeExceptionForDepth(); } IntPtr offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(depth, 0, 0)); int length = checked(array.GetLength(1) * array.GetLength(2)); return new RawObjectMemoryManager<T>(array, offset, length).Memory; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span2D<T> AsSpan2D<T>(this T[,,] array, int depth) { return new Span2D<T>(array, depth); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory2D<T> AsMemory2D<T>(this T[,,] array, int depth) { return new Memory2D<T>(array, depth); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Count<T>(this T[,,] array, T value) where T : IEquatable<T> { ref T r = ref array.DangerousGetReference(); nint arrayNativeLength = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayNativeLength(array); nint num = SpanHelper.Count(ref r, arrayNativeLength, value); if ((nuint)num > (nuint)2147483647u) { ThrowOverflowException(); } return (int)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetDjb2HashCode<T>(this T[,,] array) where T : notnull { ref T r = ref array.DangerousGetReference(); nint arrayNativeLength = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArrayNativeLength(array); return SpanHelper.GetDjb2HashCode(ref r, arrayNativeLength); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool IsCovariant<T>(this T[,,] array) { if (default(T) == null) { return array.GetType() != typeof(T[,,]); } return false; } private static void ThrowArgumentOutOfRangeExceptionForDepth() { throw new ArgumentOutOfRangeException("depth"); } } public static class ArrayPoolBufferWriterExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Stream AsStream(this ArrayPoolBufferWriter<byte> writer) { return new IBufferWriterStream<ArrayBufferWriterOwner>(new ArrayBufferWriterOwner(writer)); } } public static class ArrayPoolExtensions { public static void Resize<T>(this ArrayPool<T> pool, ref T[]? array, int newSize, bool clearArray = false) { if (array == null) { array = pool.Rent(newSize); } else if (array.Length != newSize) { T[] array2 = pool.Rent(newSize); int length = Math.Min(array.Length, newSize); Array.Copy(array, 0, array2, 0, length); pool.Return(array, clearArray); array = array2; } } } public static class BoolExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static byte ToByte(this bool flag) { bool flag2 = flag; return flag2 ? ((byte)1) : ((byte)0); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int ToBitwiseMask32(this bool flag) { bool flag2 = flag; return ~((flag2 ? 1 : 0) - 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long ToBitwiseMask64(this bool flag) { bool flag2 = flag; return ~((flag2 ? 1L : 0L) - 1L); } } public static class HashCodeExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Add<T>(this ref HashCode hashCode, ReadOnlySpan<T> span) where T : notnull { int value = HashCode<T>.CombineValues(span); hashCode.Add(value); } } public static class IBufferWriterExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Stream AsStream(this IBufferWriter<byte> writer) { if (writer.GetType() == typeof(ArrayPoolBufferWriter<byte>)) { return new IBufferWriterStream<ArrayBufferWriterOwner>(new ArrayBufferWriterOwner(Unsafe.As<ArrayPoolBufferWriter<byte>>(writer))); } return new IBufferWriterStream<IBufferWriterOwner>(new IBufferWriterOwner(writer)); } public static void Write<T>(this IBufferWriter<byte> writer, T value) where T : unmanaged { int num = Unsafe.SizeOf<T>(); Span<byte> span = writer.GetSpan(1); if (span.Length < num) { ThrowArgumentExceptionForEndOfBuffer(); } Unsafe.WriteUnaligned(ref MemoryMarshal.GetReference(span), value); writer.Advance(num); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this IBufferWriter<T> writer, T value) { Span<T> span = writer.GetSpan(1); if (span.Length < 1) { ThrowArgumentExceptionForEndOfBuffer(); } MemoryMarshal.GetReference(span) = value; writer.Advance(1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this IBufferWriter<byte> writer, ReadOnlySpan<T> span) where T : unmanaged { ReadOnlySpan<byte> readOnlySpan = MemoryMarshal.AsBytes(span); Span<byte> span2 = writer.GetSpan(readOnlySpan.Length); readOnlySpan.CopyTo(span2); writer.Advance(readOnlySpan.Length); } private static void ThrowArgumentExceptionForEndOfBuffer() { throw new ArgumentException("The current buffer writer can't contain the requested input data."); } } public static class IMemoryOwnerExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Stream AsStream(this IMemoryOwner<byte> memoryOwner) { return Microsoft.Toolkit.HighPerformance.Streams.MemoryStream.Create(memoryOwner); } } public static class MemoryExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory2D<T> AsMemory2D<T>(this Memory<T> memory, int height, int width) { return new Memory2D<T>(memory, height, width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory2D<T> AsMemory2D<T>(this Memory<T> memory, int offset, int height, int width, int pitch) { return new Memory2D<T>(memory, offset, height, width, pitch); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory<byte> AsBytes<T>(this Memory<T> memory) where T : unmanaged { return MemoryMarshal.AsMemory(ReadOnlyMemoryExtensions.Cast<T, byte>(memory)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Memory<TTo> Cast<TFrom, TTo>(this Memory<TFrom> memory) where TFrom : unmanaged where TTo : unmanaged { return MemoryMarshal.AsMemory(ReadOnlyMemoryExtensions.Cast<TFrom, TTo>(memory)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Stream AsStream(this Memory<byte> memory) { return Microsoft.Toolkit.HighPerformance.Streams.MemoryStream.Create(memory, isReadOnly: false); } } public static class ReadOnlyMemoryExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlyMemory2D<T> AsMemory2D<T>(this ReadOnlyMemory<T> memory, int height, int width) { return new ReadOnlyMemory2D<T>(memory, height, width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlyMemory2D<T> AsMemory2D<T>(this ReadOnlyMemory<T> memory, int offset, int height, int width, int pitch) { return new ReadOnlyMemory2D<T>(memory, offset, height, width, pitch); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlyMemory<byte> AsBytes<T>(this ReadOnlyMemory<T> memory) where T : unmanaged { return memory.Cast<T, byte>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlyMemory<TTo> Cast<TFrom, TTo>(this ReadOnlyMemory<TFrom> memory) where TFrom : unmanaged where TTo : unmanaged { if (memory.IsEmpty) { return default(ReadOnlyMemory<TTo>); } if (typeof(TFrom) == typeof(char) && MemoryMarshal.TryGetString((ReadOnlyMemory<char>)(object)memory, out string text, out int start, out int length)) { return new StringMemoryManager<TTo>(text, start, length).Memory; } if (MemoryMarshal.TryGetArray(memory, out var segment)) { return new ArrayMemoryManager<TFrom, TTo>(segment.Array, segment.Offset, segment.Count).Memory; } if (MemoryMarshal.TryGetMemoryManager<TFrom, MemoryManager<TFrom>>(memory, out MemoryManager<TFrom> manager, out start, out length)) { if (manager is IMemoryManager memoryManager) { return memoryManager.GetMemory<TTo>(start, length); } return new ProxyMemoryManager<TFrom, TTo>(manager, start, length).Memory; } return ThrowArgumentExceptionForUnsupportedMemory(); static ReadOnlyMemory<TTo> ThrowArgumentExceptionForUnsupportedMemory() { throw new ArgumentException("The input instance doesn't have a supported underlying data store."); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Stream AsStream(this ReadOnlyMemory<byte> memory) { return Microsoft.Toolkit.HighPerformance.Streams.MemoryStream.Create(memory, isReadOnly: true); } } public static class ReadOnlySpanExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReference<T>(this ReadOnlySpan<T> span) { return ref MemoryMarshal.GetReference(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this ReadOnlySpan<T> span, int i) { return ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)i); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this ReadOnlySpan<T> span, nint i) { return ref Unsafe.Add(ref MemoryMarshal.GetReference(span), i); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref readonly T DangerousGetLookupReferenceAt<T>(this ReadOnlySpan<T> span, int i) { bool flag = (uint)i < (uint)span.Length; uint num = (uint)(~((flag ? 1 : 0) - 1)); uint num2 = (uint)i & num; return ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)num2); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan2D<T> AsSpan2D<T>(this ReadOnlySpan<T> span, int height, int width) { return new ReadOnlySpan2D<T>(span, height, width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan2D<T> AsSpan2D<T>(this ReadOnlySpan<T> span, int offset, int height, int width, int pitch) { return new ReadOnlySpan2D<T>(span, offset, height, width, pitch); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf<T>(this ReadOnlySpan<T> span, in T value) { nint num = (nint)Unsafe.ByteOffset(in MemoryMarshal.GetReference(span), in Unsafe.AsRef(in value)) / (nint)(uint)Unsafe.SizeOf<T>(); if ((nuint)num >= (nuint)(uint)span.Length) { SpanExtensions.ThrowArgumentOutOfRangeExceptionForInvalidReference(); } return (int)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Count<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T> { ref T reference = ref MemoryMarshal.GetReference(span); nint length = (nint)(uint)span.Length; return (int)SpanHelper.Count(ref reference, length, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan<byte> AsBytes<T>(this ReadOnlySpan<T> span) where T : unmanaged { return MemoryMarshal.AsBytes(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpan<TTo> Cast<TFrom, TTo>(this ReadOnlySpan<TFrom> span) where TFrom : unmanaged where TTo : unmanaged { return MemoryMarshal.Cast<TFrom, TTo>(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpanEnumerable<T> Enumerate<T>(this ReadOnlySpan<T> span) { return new ReadOnlySpanEnumerable<T>(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpanTokenizer<T> Tokenize<T>(this ReadOnlySpan<T> span, T separator) where T : IEquatable<T> { return new ReadOnlySpanTokenizer<T>(span, separator); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetDjb2HashCode<T>(this ReadOnlySpan<T> span) where T : notnull { ref T reference = ref MemoryMarshal.GetReference(span); nint length = (nint)(uint)span.Length; return SpanHelper.GetDjb2HashCode(ref reference, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CopyTo<T>(this ReadOnlySpan<T> span, RefEnumerable<T> destination) { destination.CopyFrom(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryCopyTo<T>(this ReadOnlySpan<T> span, RefEnumerable<T> destination) { return destination.TryCopyFrom(span); } } public static class SpanExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReference<T>(this Span<T> span) { return ref MemoryMarshal.GetReference(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this Span<T> span, int i) { return ref Unsafe.Add(ref MemoryMarshal.GetReference(span), (nint)(uint)i); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T DangerousGetReferenceAt<T>(this Span<T> span, nint i) { return ref Unsafe.Add(ref MemoryMarshal.GetReference(span), i); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span2D<T> AsSpan2D<T>(this Span<T> span, int height, int width) { return new Span2D<T>(span, height, width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span2D<T> AsSpan2D<T>(this Span<T> span, int offset, int height, int width, int pitch) { return new Span2D<T>(span, offset, height, width, pitch); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<byte> AsBytes<T>(this Span<T> span) where T : unmanaged { return MemoryMarshal.AsBytes(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Span<TTo> Cast<TFrom, TTo>(this Span<TFrom> span) where TFrom : unmanaged where TTo : unmanaged { return MemoryMarshal.Cast<TFrom, TTo>(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int IndexOf<T>(this Span<T> span, ref T value) { nint num = (nint)Unsafe.ByteOffset(in MemoryMarshal.GetReference(span), in value) / (nint)(uint)Unsafe.SizeOf<T>(); if ((nuint)num >= (nuint)(uint)span.Length) { ThrowArgumentOutOfRangeExceptionForInvalidReference(); } return (int)num; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Count<T>(this Span<T> span, T value) where T : IEquatable<T> { ref T reference = ref MemoryMarshal.GetReference(span); nint length = (nint)(uint)span.Length; return (int)SpanHelper.Count(ref reference, length, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SpanEnumerable<T> Enumerate<T>(this Span<T> span) { return new SpanEnumerable<T>(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static SpanTokenizer<T> Tokenize<T>(this Span<T> span, T separator) where T : IEquatable<T> { return new SpanTokenizer<T>(span, separator); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetDjb2HashCode<T>(this Span<T> span) where T : notnull { ref T reference = ref MemoryMarshal.GetReference(span); nint length = (nint)(uint)span.Length; return SpanHelper.GetDjb2HashCode(ref reference, length); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void CopyTo<T>(this Span<T> span, RefEnumerable<T> destination) { destination.CopyFrom(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool TryCopyTo<T>(this Span<T> span, RefEnumerable<T> destination) { return destination.TryCopyFrom(span); } internal static void ThrowArgumentOutOfRangeExceptionForInvalidReference() { throw new ArgumentOutOfRangeException("value", "The input reference does not belong to an element of the input span"); } } public static class SpinLockExtensions { [EditorBrowsable(EditorBrowsableState.Never)] public readonly ref struct UnsafeLock { private unsafe readonly SpinLock* spinLock; private readonly bool lockTaken; [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe UnsafeLock(SpinLock* spinLock) { this.spinLock = spinLock; lockTaken = false; spinLock->Enter(ref lockTaken); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe void Dispose() { if (lockTaken) { spinLock->Exit(); } } } [EditorBrowsable(EditorBrowsableState.Never)] public readonly ref struct Lock { private readonly Ref<SpinLock> spinLock; private readonly bool lockTaken; [MethodImpl(MethodImplOptions.AggressiveInlining)] public Lock(ref SpinLock spinLock) { this.spinLock = new Ref<SpinLock>(ref spinLock); lockTaken = false; spinLock.Enter(ref lockTaken); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Dispose() { if (lockTaken) { spinLock.Value.Exit(); } } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static UnsafeLock Enter(SpinLock* spinLock) { return new UnsafeLock(spinLock); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Lock Enter(this ref SpinLock spinLock) { return new Lock(ref spinLock); } } public static class StreamExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe static T Read<T>(this Stream stream) where T : unmanaged { T result = default(T); int num = Unsafe.SizeOf<T>(); if (stream.Read(new Span<byte>(&result, num)) != num) { ThrowInvalidOperationExceptionForEndOfStream(); } return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Write<T>(this Stream stream, in T value) where T : unmanaged { ref byte reference = ref Unsafe.As<T, byte>(ref Unsafe.AsRef(in value)); int length = Unsafe.SizeOf<T>(); ReadOnlySpan<byte> buffer = MemoryMarshal.CreateReadOnlySpan(in reference, length); stream.Write(buffer); } private static void ThrowInvalidOperationExceptionForEndOfStream() { throw new InvalidOperationException("The stream didn't contain enough data to read the requested item"); } } public static class StringExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref char DangerousGetReference(this string text) { return ref MemoryMarshal.GetReference(text.AsSpan()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref char DangerousGetReferenceAt(this string text, int i) { return ref Unsafe.Add(ref MemoryMarshal.GetReference(text.AsSpan()), (nint)(uint)i); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Count(this string text, char c) { ref char r = ref text.DangerousGetReference(); nint length = (nint)(uint)text.Length; return (int)SpanHelper.Count(ref r, length, c); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpanEnumerable<char> Enumerate(this string text) { return new ReadOnlySpanEnumerable<char>(text.AsSpan()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ReadOnlySpanTokenizer<char> Tokenize(this string text, char separator) { return new ReadOnlySpanTokenizer<char>(text.AsSpan(), separator); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int GetDjb2HashCode(this string text) { ref char r = ref text.DangerousGetReference(); nint length = (nint)(uint)text.Length; return SpanHelper.GetDjb2HashCode(ref r, length); } } [DebuggerTypeProxy(typeof(MemoryDebugView2D<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly struct Memory2D<T> : IEquatable<Memory2D<T>> { private readonly object? instance; private readonly IntPtr offset; private readonly int height; private readonly int width; private readonly int pitch; public static Memory2D<T> Empty => default(Memory2D<T>); public bool IsEmpty { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (height != 0) { return width == 0; } return true; } } public nint Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return (nint)(uint)height * (nint)(uint)width; } } public int Height { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return height; } } public int Width { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return width; } } public Span2D<T> Span { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (instance != null) { if (instance is MemoryManager<T> memoryManager) { return new Span2D<T>(ref Unsafe.Add(ref memoryManager.GetSpan().DangerousGetReference(), offset), height, width, pitch); } return new Span2D<T>(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(instance, offset), height, width, pitch); } return default(Span2D<T>); } } public Memory2D<T> this[Range rows, Range columns] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { var (row, num) = rows.GetOffsetAndLength(height); var (column, num2) = columns.GetOffsetAndLength(width); return Slice(row, column, num, num2); } } public Memory2D(T[] array, int height, int width) : this(array, 0, height, width, 0) { } public Memory2D(T[] array, int offset, int height, int width, int pitch) { if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)offset > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = array.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } instance = array; this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(offset)); this.height = height; this.width = width; this.pitch = pitch; } public Memory2D(T[,]? array) { if (array == null) { this = default(Memory2D<T>); return; } if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } instance = array; offset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray2DDataByteOffset<T>(); height = array.GetLength(0); width = array.GetLength(1); pitch = 0; } public Memory2D(T[,]? array, int row, int column, int height, int width) { if (array == null) { if (row != 0 || column != 0 || height != 0 || width != 0) { ThrowHelper.ThrowArgumentException(); } this = default(Memory2D<T>); return; } if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } int length = array.GetLength(0); int length2 = array.GetLength(1); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } instance = array; offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(row, column)); this.height = height; this.width = width; pitch = length2 - width; } public Memory2D(T[,,] array, int depth) { if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } instance = array; offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(depth, 0, 0)); height = array.GetLength(1); width = array.GetLength(2); pitch = 0; } public Memory2D(T[,,] array, int depth, int row, int column, int height, int width) { if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } int length = array.GetLength(1); int length2 = array.GetLength(2); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } instance = array; offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(depth, row, column)); this.height = height; this.width = width; pitch = length2 - width; } public Memory2D(MemoryManager<T> memoryManager, int height, int width) : this(memoryManager, 0, height, width, 0) { } public Memory2D(MemoryManager<T> memoryManager, int offset, int height, int width, int pitch) { int length = memoryManager.GetSpan().Length; if ((uint)offset > (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(Memory2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } instance = memoryManager; this.offset = (nint)(uint)offset; this.height = height; this.width = width; this.pitch = pitch; } internal Memory2D(Memory<T> memory, int height, int width) : this(memory, 0, height, width, 0) { } internal Memory2D(Memory<T> memory, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)memory.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(Memory2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = memory.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } ArraySegment<T> segment; MemoryManager<T> manager; int start2; if (typeof(T) == typeof(char) && MemoryMarshal.TryGetString(Unsafe.As<Memory<T>, Memory<char>>(ref memory), out string text, out int start, out int length)) { ref char data = ref text.DangerousGetReferenceAt(start + offset); instance = text; this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(text, ref data); } else if (MemoryMarshal.TryGetArray((ReadOnlyMemory<T>)memory, out segment)) { T[] array = (T[])(instance = segment.Array); this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(segment.Offset + offset)); } else if (MemoryMarshal.TryGetMemoryManager<T, MemoryManager<T>>(memory, out manager, out start2, out length)) { instance = manager; this.offset = (nint)(uint)(start2 + offset); } else { ThrowHelper.ThrowArgumentExceptionForUnsupportedType(); instance = null; this.offset = default(IntPtr); } this.height = height; this.width = width; this.pitch = pitch; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private Memory2D(object instance, IntPtr offset, int height, int width, int pitch) { this.instance = instance; this.offset = offset; this.height = height; this.width = width; this.pitch = pitch; } public static Memory2D<T> DangerousCreate(object instance, ref T value, int height, int width, int pitch) { if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); IntPtr intPtr = ObjectMarshal.DangerousGetObjectDataByteOffset(instance, ref value); return new Memory2D<T>(instance, intPtr, height, width, pitch); } public Memory2D<T> Slice(int row, int column, int height, int width) { if ((uint)row >= Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= this.width) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > Height - row) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > this.width - column) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } int num = (this.width + pitch) * row + column; int num2 = pitch + (this.width - width); IntPtr intPtr = offset + num * Unsafe.SizeOf<T>(); return new Memory2D<T>(instance, intPtr, height, width, num2); } public void CopyTo(Memory<T> destination) { Span.CopyTo(destination.Span); } public bool TryCopyTo(Memory<T> destination) { return Span.TryCopyTo(destination.Span); } public void CopyTo(Memory2D<T> destination) { Span.CopyTo(destination.Span); } public bool TryCopyTo(Memory2D<T> destination) { return Span.TryCopyTo(destination.Span); } public unsafe MemoryHandle Pin() { if (instance != null) { if (instance is MemoryManager<T> memoryManager) { return memoryManager.Pin(); } GCHandle handle = GCHandle.Alloc(instance, GCHandleType.Pinned); return new MemoryHandle(Unsafe.AsPointer(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(instance, offset)), handle); } return default(MemoryHandle); } public bool TryGetMemory(out Memory<T> memory) { if (pitch == 0 && Length <= int.MaxValue) { if (instance == null) { memory = default(Memory<T>); } else if (typeof(T) == typeof(char) && instance.GetType() == typeof(string)) { string text = Unsafe.As<string>(instance); int start = text.AsSpan().IndexOf(in ObjectMarshal.DangerousGetObjectDataReferenceAt<char>(text, offset)); ReadOnlyMemory<char> source = text.AsMemory(start, (int)Length); memory = MemoryMarshal.AsMemory<T>(Unsafe.As<ReadOnlyMemory<char>, Memory<T>>(ref source)); } else if (instance is MemoryManager<T> memoryManager) { memory = memoryManager.Memory.Slice((int)(nint)offset, height * width); } else if (instance.GetType() == typeof(T[])) { T[] array = Unsafe.As<T[]>(instance); int start2 = array.AsSpan().IndexOf(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, offset)); memory = array.AsMemory(start2, height * width); } else { if (!(instance.GetType() == typeof(T[,])) && !(instance.GetType() == typeof(T[,,]))) { goto IL_01bd; } memory = new RawObjectMemoryManager<T>(instance, offset, height * width).Memory; } return true; } goto IL_01bd; IL_01bd: memory = default(Memory<T>); return false; } public T[,] ToArray() { return Span.ToArray(); } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object? obj) { if (obj is Memory2D<T> other) { return Equals(other); } if (obj is ReadOnlyMemory2D<T> readOnlyMemory2D) { return readOnlyMemory2D.Equals(this); } return false; } public bool Equals(Memory2D<T> other) { if (instance == other.instance && offset == other.offset && height == other.height && width == other.width) { return pitch == other.pitch; } return false; } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { if (instance != null) { return HashCode.Combine(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(instance), offset, height, width, pitch); } return 0; } public override string ToString() { return $"Microsoft.Toolkit.HighPerformance.Memory2D<{typeof(T)}>[{height}, {width}]"; } public static implicit operator Memory2D<T>(T[,]? array) { return new Memory2D<T>(array); } } [DebuggerTypeProxy(typeof(MemoryDebugView2D<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly struct ReadOnlyMemory2D<T> : IEquatable<ReadOnlyMemory2D<T>> { private readonly object? instance; private readonly IntPtr offset; private readonly int height; private readonly int width; private readonly int pitch; public static ReadOnlyMemory2D<T> Empty => default(ReadOnlyMemory2D<T>); public bool IsEmpty { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (height != 0) { return width == 0; } return true; } } public nint Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return (nint)(uint)height * (nint)(uint)width; } } public int Height { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return height; } } public int Width { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return width; } } public ReadOnlySpan2D<T> Span { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (instance != null) { if (instance is MemoryManager<T> memoryManager) { return new ReadOnlySpan2D<T>(in Unsafe.Add(ref memoryManager.GetSpan().DangerousGetReference(), offset), height, width, pitch); } return new ReadOnlySpan2D<T>(in ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(instance, offset), height, width, pitch); } return default(ReadOnlySpan2D<T>); } } public ReadOnlyMemory2D<T> this[Range rows, Range columns] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { var (row, num) = rows.GetOffsetAndLength(height); var (column, num2) = columns.GetOffsetAndLength(width); return Slice(row, column, num, num2); } } public ReadOnlyMemory2D(string text, int height, int width) : this(text, 0, height, width, 0) { } public ReadOnlyMemory2D(string text, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)text.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = text.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } instance = text; this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(text, ref text.DangerousGetReferenceAt(offset)); this.height = height; this.width = width; this.pitch = pitch; } public ReadOnlyMemory2D(T[] array, int height, int width) : this(array, 0, height, width, 0) { } public ReadOnlyMemory2D(T[] array, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = array.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } instance = array; this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(offset)); this.height = height; this.width = width; this.pitch = pitch; } public ReadOnlyMemory2D(T[,]? array) { if (array == null) { this = default(ReadOnlyMemory2D<T>); return; } instance = array; offset = Microsoft.Toolkit.HighPerformance.Helpers.Internals.RuntimeHelpers.GetArray2DDataByteOffset<T>(); height = array.GetLength(0); width = array.GetLength(1); pitch = 0; } public ReadOnlyMemory2D(T[,]? array, int row, int column, int height, int width) { if (array == null) { if (row != 0 || column != 0 || height != 0 || width != 0) { ThrowHelper.ThrowArgumentException(); } this = default(ReadOnlyMemory2D<T>); return; } int length = array.GetLength(0); int length2 = array.GetLength(1); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } instance = array; offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(row, column)); this.height = height; this.width = width; pitch = length2 - width; } public ReadOnlyMemory2D(T[,,] array, int depth) { if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } instance = array; offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(depth, 0, 0)); height = array.GetLength(1); width = array.GetLength(2); pitch = 0; } public ReadOnlyMemory2D(T[,,] array, int depth, int row, int column, int height, int width) { if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } int length = array.GetLength(1); int length2 = array.GetLength(2); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } instance = array; offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(depth, row, column)); this.height = height; this.width = width; pitch = length2 - width; } public ReadOnlyMemory2D(MemoryManager<T> memoryManager, int height, int width) : this(memoryManager, 0, height, width, 0) { } public ReadOnlyMemory2D(MemoryManager<T> memoryManager, int offset, int height, int width, int pitch) { int length = memoryManager.GetSpan().Length; if ((uint)offset > (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(ReadOnlyMemory2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } instance = memoryManager; this.offset = (nint)(uint)offset; this.height = height; this.width = width; this.pitch = pitch; } internal ReadOnlyMemory2D(ReadOnlyMemory<T> memory, int height, int width) : this(memory, 0, height, width, 0) { } internal ReadOnlyMemory2D(ReadOnlyMemory<T> memory, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)memory.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(ReadOnlyMemory2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = memory.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } ArraySegment<T> segment; MemoryManager<T> manager; int start2; if (typeof(T) == typeof(char) && MemoryMarshal.TryGetString(Unsafe.As<ReadOnlyMemory<T>, ReadOnlyMemory<char>>(ref memory), out string text, out int start, out int length)) { ref char data = ref text.DangerousGetReferenceAt(start + offset); instance = text; this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(text, ref data); } else if (MemoryMarshal.TryGetArray(memory, out segment)) { T[] array = (T[])(instance = segment.Array); this.offset = ObjectMarshal.DangerousGetObjectDataByteOffset(array, ref array.DangerousGetReferenceAt(segment.Offset + offset)); } else if (MemoryMarshal.TryGetMemoryManager<T, MemoryManager<T>>(memory, out manager, out start2, out length)) { instance = manager; this.offset = (nint)(uint)(start2 + offset); } else { ThrowHelper.ThrowArgumentExceptionForUnsupportedType(); instance = null; this.offset = default(IntPtr); } this.height = height; this.width = width; this.pitch = pitch; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private ReadOnlyMemory2D(object instance, IntPtr offset, int height, int width, int pitch) { this.instance = instance; this.offset = offset; this.height = height; this.width = width; this.pitch = pitch; } public static ReadOnlyMemory2D<T> DangerousCreate(object instance, ref T value, int height, int width, int pitch) { if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); IntPtr intPtr = ObjectMarshal.DangerousGetObjectDataByteOffset(instance, ref value); return new ReadOnlyMemory2D<T>(instance, intPtr, height, width, pitch); } public ReadOnlyMemory2D<T> Slice(int row, int column, int height, int width) { if ((uint)row >= Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= this.width) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > Height - row) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > this.width - column) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } int num = (this.width + pitch) * row + column; int num2 = pitch + (this.width - width); IntPtr intPtr = offset + num * Unsafe.SizeOf<T>(); return new ReadOnlyMemory2D<T>(instance, intPtr, height, width, num2); } public void CopyTo(Memory<T> destination) { Span.CopyTo(destination.Span); } public bool TryCopyTo(Memory<T> destination) { return Span.TryCopyTo(destination.Span); } public void CopyTo(Memory2D<T> destination) { Span.CopyTo(destination.Span); } public bool TryCopyTo(Memory2D<T> destination) { return Span.TryCopyTo(destination.Span); } public unsafe MemoryHandle Pin() { if (instance != null) { if (instance is MemoryManager<T> memoryManager) { return memoryManager.Pin(); } GCHandle handle = GCHandle.Alloc(instance, GCHandleType.Pinned); return new MemoryHandle(Unsafe.AsPointer(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(instance, offset)), handle); } return default(MemoryHandle); } public bool TryGetMemory(out ReadOnlyMemory<T> memory) { if (pitch == 0 && Length <= int.MaxValue) { if (instance == null) { memory = default(ReadOnlyMemory<T>); } else if (typeof(T) == typeof(char) && instance.GetType() == typeof(string)) { string text = Unsafe.As<string>(instance); int start = text.AsSpan().IndexOf(in ObjectMarshal.DangerousGetObjectDataReferenceAt<char>(text, offset)); ReadOnlyMemory<char> source = text.AsMemory(start, (int)Length); memory = Unsafe.As<ReadOnlyMemory<char>, ReadOnlyMemory<T>>(ref source); } else if (instance is MemoryManager<T> memoryManager) { memory = memoryManager.Memory.Slice((int)(nint)offset, height * width); } else if (instance.GetType() == typeof(T[])) { T[] array = Unsafe.As<T[]>(instance); int start2 = array.AsSpan().IndexOf(ref ObjectMarshal.DangerousGetObjectDataReferenceAt<T>(array, offset)); memory = array.AsMemory(start2, height * width); } else { if (!(instance.GetType() == typeof(T[,])) && !(instance.GetType() == typeof(T[,,]))) { goto IL_01c2; } memory = new RawObjectMemoryManager<T>(instance, offset, height * width).Memory; } return true; } goto IL_01c2; IL_01c2: memory = default(ReadOnlyMemory<T>); return false; } public T[,] ToArray() { return Span.ToArray(); } [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object? obj) { if (obj is ReadOnlyMemory2D<T> other) { return Equals(other); } if (obj is Memory2D<T> memory2D) { return Equals(memory2D); } return false; } public bool Equals(ReadOnlyMemory2D<T> other) { if (instance == other.instance && offset == other.offset && height == other.height && width == other.width) { return pitch == other.pitch; } return false; } [EditorBrowsable(EditorBrowsableState.Never)] public override int GetHashCode() { if (instance != null) { return HashCode.Combine(System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode(instance), offset, height, width, pitch); } return 0; } public override string ToString() { return $"Microsoft.Toolkit.HighPerformance.ReadOnlyMemory2D<{typeof(T)}>[{height}, {width}]"; } public static implicit operator ReadOnlyMemory2D<T>(T[,]? array) { return new ReadOnlyMemory2D<T>(array); } public static implicit operator ReadOnlyMemory2D<T>(Memory2D<T> memory) { return Unsafe.As<Memory2D<T>, ReadOnlyMemory2D<T>>(ref memory); } } [DebuggerTypeProxy(typeof(MemoryDebugView2D<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly ref struct ReadOnlySpan2D<T> { public ref struct Enumerator { private readonly ReadOnlySpan<T> span; private readonly int width; private readonly int stride; private int x; private int y; public readonly ref readonly T Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ref T reference = ref MemoryMarshal.GetReference(span); nint elementOffset = (nint)(uint)y * (nint)(uint)stride + (nint)(uint)x; return ref Unsafe.Add(ref reference, elementOffset); } } internal Enumerator(ReadOnlySpan2D<T> span) { this.span = span.span; width = span.width; stride = span.stride; x = -1; y = 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { int num = x + 1; if (num < width) { x = num; return true; } x = 0; return ++y < span.Length; } } private readonly ReadOnlySpan<T> span; private readonly int width; private readonly int stride; public static ReadOnlySpan2D<T> Empty => default(ReadOnlySpan2D<T>); public bool IsEmpty { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (Height != 0) { return width == 0; } return true; } } public nint Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return (nint)(uint)Height * (nint)(uint)width; } } public int Height { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return span.Length; } } public int Width { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return width; } } public ref readonly T this[int row, int column] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if ((uint)row >= (uint)Height || (uint)column >= (uint)Width) { ThrowHelper.ThrowIndexOutOfRangeException(); } return ref DangerousGetReferenceAt(row, column); } } public ref readonly T this[Index row, Index column] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref this[row.GetOffset(Height), column.GetOffset(width)]; } } public ReadOnlySpan2D<T> this[Range rows, Range columns] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { var (row, height) = rows.GetOffsetAndLength(Height); var (column, num) = columns.GetOffsetAndLength(width); return Slice(row, column, height, num); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal ReadOnlySpan2D(in T value, int height, int width, int pitch) { span = MemoryMarshal.CreateReadOnlySpan(in Unsafe.AsRef(in value), height); this.width = width; stride = width + pitch; } public unsafe ReadOnlySpan2D(void* pointer, int height, int width, int pitch) { if (System.Runtime.CompilerServices.RuntimeHelpers.IsReferenceOrContainsReferences<T>()) { ThrowHelper.ThrowArgumentExceptionForManagedType(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); span = new ReadOnlySpan<T>(pointer, height); this.width = width; stride = width + pitch; } public ReadOnlySpan2D(T[] array, int height, int width) : this(array, 0, height, width, 0) { } public ReadOnlySpan2D(T[] array, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(ReadOnlySpan2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = array.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } span = MemoryMarshal.CreateReadOnlySpan(in array.DangerousGetReferenceAt(offset), height); this.width = width; stride = width + pitch; } public ReadOnlySpan2D(T[,]? array) { if (array == null) { this = default(ReadOnlySpan2D<T>); return; } span = MemoryMarshal.CreateReadOnlySpan(in array.DangerousGetReference(), array.GetLength(0)); width = (stride = array.GetLength(1)); } public ReadOnlySpan2D(T[,]? array, int row, int column, int height, int width) { if (array == null) { if (row != 0 || column != 0 || height != 0 || width != 0) { ThrowHelper.ThrowArgumentException(); } this = default(ReadOnlySpan2D<T>); return; } int length = array.GetLength(0); int length2 = array.GetLength(1); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } span = MemoryMarshal.CreateReadOnlySpan(in array.DangerousGetReferenceAt(row, column), height); this.width = width; stride = length2; } public ReadOnlySpan2D(T[,,] array, int depth) { if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } span = MemoryMarshal.CreateReadOnlySpan(in array.DangerousGetReferenceAt(depth, 0, 0), array.GetLength(1)); width = (stride = array.GetLength(2)); } public ReadOnlySpan2D(T[,,] array, int depth, int row, int column, int height, int width) { if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } int length = array.GetLength(1); int length2 = array.GetLength(2); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } span = MemoryMarshal.CreateReadOnlySpan(in array.DangerousGetReferenceAt(depth, row, column), height); this.width = width; stride = length2; } internal ReadOnlySpan2D(ReadOnlySpan<T> span, int height, int width) : this(span, 0, height, width, 0) { } internal ReadOnlySpan2D(ReadOnlySpan<T> span, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)span.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(ReadOnlySpan2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = span.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } this.span = MemoryMarshal.CreateSpan(ref span.DangerousGetReferenceAt(offset), height); this.width = width; stride = width + pitch; } public static ReadOnlySpan2D<T> DangerousCreate(in T value, int height, int width, int pitch) { if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); return new ReadOnlySpan2D<T>(in value, height, width, pitch); } public void CopyTo(Span<T> destination) { if (IsEmpty) { return; } if (TryGetSpan(out var readOnlySpan)) { readOnlySpan.CopyTo(destination); return; } if (Length > destination.Length) { ThrowHelper.ThrowArgumentExceptionForDestinationTooShort(); } int num = 0; int num2 = 0; while (num < Height) { GetRowSpan(num).CopyTo(destination.Slice(num2)); num++; num2 += width; } } public void CopyTo(Span2D<T> destination) { if (destination.Height != Height || destination.Width != Width) { ThrowHelper.ThrowArgumentExceptionForDestinationWithNotSameShape(); } if (IsEmpty) { return; } if (destination.TryGetSpan(out Span<T> destination2)) { CopyTo(destination2); return; } for (int i = 0; i < Height; i++) { GetRowSpan(i).CopyTo(destination.GetRowSpan(i)); } } public bool TryCopyTo(Span<T> destination) { if (destination.Length >= Length) { CopyTo(destination); return true; } return false; } public bool TryCopyTo(Span2D<T> destination) { if (destination.Height == Height && destination.Width == Width) { CopyTo(destination); return true; } return false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [EditorBrowsable(EditorBrowsableState.Never)] public unsafe ref T GetPinnableReference() { ref T result = ref Unsafe.AsRef<T>(null); if (Length != 0) { result = ref MemoryMarshal.GetReference(span); } return ref result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReference() { return ref MemoryMarshal.GetReference(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReferenceAt(int i, int j) { ref T reference = ref MemoryMarshal.GetReference(span); nint elementOffset = (nint)(uint)i * (nint)(uint)stride + (nint)(uint)j; return ref Unsafe.Add(ref reference, elementOffset); } public ReadOnlySpan2D<T> Slice(int row, int column, int height, int width) { if ((uint)row >= Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= this.width) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > Height - row) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > this.width - column) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } nint i = (nint)(uint)stride * (nint)(uint)row + (nint)(uint)column; int pitch = stride - width; return new ReadOnlySpan2D<T>(in span.DangerousGetReferenceAt(i), height, width, pitch); } public ReadOnlySpan<T> GetRowSpan(int row) { if ((uint)row >= (uint)Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } return MemoryMarshal.CreateReadOnlySpan(in DangerousGetReferenceAt(row, 0), width); } public bool TryGetSpan(out ReadOnlySpan<T> span) { if (stride == width && Length <= int.MaxValue) { span = MemoryMarshal.CreateReadOnlySpan(in MemoryMarshal.GetReference(this.span), (int)Length); return true; } span = default(ReadOnlySpan<T>); return false; } public T[,] ToArray() { T[,] array = new T[Height, width]; CopyTo(array.AsSpan()); return array; } [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Equals() on Span will always throw an exception. Use == instead.")] public override bool Equals(object? obj) { throw new NotSupportedException("Microsoft.Toolkit.HighPerformance.ReadOnlySpan2D<T>.Equals(object) is not supported"); } [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("GetHashCode() on Span will always throw an exception.")] public override int GetHashCode() { throw new NotSupportedException("Microsoft.Toolkit.HighPerformance.ReadOnlySpan2D<T>.GetHashCode() is not supported"); } public override string ToString() { return $"Microsoft.Toolkit.HighPerformance.ReadOnlySpan2D<{typeof(T)}>[{Height}, {width}]"; } public static bool operator ==(ReadOnlySpan2D<T> left, ReadOnlySpan2D<T> right) { if (left.span == right.span && left.width == right.width) { return left.stride == right.stride; } return false; } public static bool operator !=(ReadOnlySpan2D<T> left, ReadOnlySpan2D<T> right) { return !(left == right); } public static implicit operator ReadOnlySpan2D<T>(T[,]? array) { return new ReadOnlySpan2D<T>(array); } public static implicit operator ReadOnlySpan2D<T>(Span2D<T> span) { return new ReadOnlySpan2D<T>(in span.DangerousGetReference(), span.Height, span.Width, span.Stride - span.Width); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyRefEnumerable<T> GetRow(int row) { if ((uint)row >= Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } nint elementOffset = (nint)(uint)stride * (nint)(uint)row; return new ReadOnlyRefEnumerable<T>(in Unsafe.Add(ref DangerousGetReference(), elementOffset), Width, 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyRefEnumerable<T> GetColumn(int column) { if ((uint)column >= Width) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } return new ReadOnlyRefEnumerable<T>(in Unsafe.Add(ref DangerousGetReference(), (nint)(uint)column), Height, stride); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Enumerator GetEnumerator() { return new Enumerator(this); } } [DebuggerTypeProxy(typeof(MemoryDebugView2D<>))] [DebuggerDisplay("{ToString(),raw}")] public readonly ref struct Span2D<T> { public ref struct Enumerator { private readonly Span<T> span; private readonly int width; private readonly int stride; private int x; private int y; public readonly ref T Current { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { ref T reference = ref MemoryMarshal.GetReference(span); nint elementOffset = (nint)(uint)y * (nint)(uint)stride + (nint)(uint)x; return ref Unsafe.Add(ref reference, elementOffset); } } internal Enumerator(Span2D<T> span) { this.span = span.span; width = span.width; stride = span.Stride; x = -1; y = 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public bool MoveNext() { int num = x + 1; if (num < width) { x = num; return true; } x = 0; return ++y < span.Length; } } private readonly Span<T> span; private readonly int width; internal readonly int Stride; public static Span2D<T> Empty => default(Span2D<T>); public bool IsEmpty { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (Height != 0) { return width == 0; } return true; } } public nint Length { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return (nint)(uint)Height * (nint)(uint)width; } } public int Height { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return span.Length; } } public int Width { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return width; } } public ref T this[int row, int column] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if ((uint)row >= (uint)Height || (uint)column >= (uint)width) { ThrowHelper.ThrowIndexOutOfRangeException(); } return ref DangerousGetReferenceAt(row, column); } } public ref T this[Index row, Index column] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref this[row.GetOffset(Height), column.GetOffset(width)]; } } public Span2D<T> this[Range rows, Range columns] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { var (row, height) = rows.GetOffsetAndLength(Height); var (column, num) = columns.GetOffsetAndLength(width); return Slice(row, column, height, num); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal Span2D(ref T value, int height, int width, int pitch) { span = MemoryMarshal.CreateSpan(ref value, height); this.width = width; Stride = width + pitch; } public unsafe Span2D(void* pointer, int height, int width, int pitch) { if (System.Runtime.CompilerServices.RuntimeHelpers.IsReferenceOrContainsReferences<T>()) { ThrowHelper.ThrowArgumentExceptionForManagedType(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); span = new Span<T>(pointer, height); this.width = width; Stride = width + pitch; } public Span2D(T[] array, int height, int width) : this(array, 0, height, width, 0) { } public Span2D(T[] array, int offset, int height, int width, int pitch) { if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)offset > (uint)array.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = array.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } span = MemoryMarshal.CreateSpan(ref array.DangerousGetReferenceAt(offset), height); this.width = width; Stride = width + pitch; } public Span2D(T[,]? array) { if (array == null) { this = default(Span2D<T>); return; } if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } span = MemoryMarshal.CreateSpan(ref array.DangerousGetReference(), array.GetLength(0)); width = (Stride = array.GetLength(1)); } public Span2D(T[,]? array, int row, int column, int height, int width) { if (array == null) { if (row != 0 || column != 0 || height != 0 || width != 0) { ThrowHelper.ThrowArgumentException(); } this = default(Span2D<T>); return; } if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } int length = array.GetLength(0); int length2 = array.GetLength(1); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } span = MemoryMarshal.CreateSpan(ref array.DangerousGetReferenceAt(row, column), height); this.width = width; Stride = length2; } public Span2D(T[,,] array, int depth) { if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } span = MemoryMarshal.CreateSpan(ref array.DangerousGetReferenceAt(depth, 0, 0), array.GetLength(1)); width = (Stride = array.GetLength(2)); } public Span2D(T[,,] array, int depth, int row, int column, int height, int width) { if (array.IsCovariant()) { ThrowHelper.ThrowArrayTypeMismatchException(); } if ((uint)depth >= (uint)array.GetLength(0)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForDepth(); } int length = array.GetLength(1); int length2 = array.GetLength(2); if ((uint)row >= (uint)length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= (uint)length2) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > (uint)(length - row)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > (uint)(length2 - column)) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } span = MemoryMarshal.CreateSpan(ref array.DangerousGetReferenceAt(depth, row, column), height); this.width = width; Stride = length2; } internal Span2D(Span<T> span, int height, int width) : this(span, 0, height, width, 0) { } internal Span2D(Span<T> span, int offset, int height, int width, int pitch) { if ((uint)offset > (uint)span.Length) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForOffset(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } if (width == 0 || height == 0) { this = default(Span2D<T>); return; } int num = OverflowHelper.ComputeInt32Area(height, width, pitch); int num2 = span.Length - offset; if (num > num2) { ThrowHelper.ThrowArgumentException(); } this.span = MemoryMarshal.CreateSpan(ref span.DangerousGetReferenceAt(offset), height); this.width = width; Stride = width + pitch; } public static Span2D<T> DangerousCreate(ref T value, int height, int width, int pitch) { if (width < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } if (height < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if (pitch < 0) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForPitch(); } OverflowHelper.EnsureIsInNativeIntRange(height, width, pitch); return new Span2D<T>(ref value, height, width, pitch); } public void Clear() { if (IsEmpty) { return; } if (TryGetSpan(out var span)) { span.Clear(); return; } for (int i = 0; i < Height; i++) { GetRowSpan(i).Clear(); } } public void CopyTo(Span<T> destination) { if (IsEmpty) { return; } if (TryGetSpan(out var span)) { span.CopyTo(destination); return; } if (Length > destination.Length) { ThrowHelper.ThrowArgumentExceptionForDestinationTooShort(); } int num = 0; int num2 = 0; while (num < Height) { GetRowSpan(num).CopyTo(destination.Slice(num2)); num++; num2 += width; } } public void CopyTo(Span2D<T> destination) { if (destination.Height != Height || destination.width != width) { ThrowHelper.ThrowArgumentExceptionForDestinationWithNotSameShape(); } if (IsEmpty) { return; } if (destination.TryGetSpan(out Span<T> destination2)) { CopyTo(destination2); return; } for (int i = 0; i < Height; i++) { GetRowSpan(i).CopyTo(destination.GetRowSpan(i)); } } public bool TryCopyTo(Span<T> destination) { if (destination.Length >= Length) { CopyTo(destination); return true; } return false; } public bool TryCopyTo(Span2D<T> destination) { if (destination.Height == Height && destination.Width == width) { CopyTo(destination); return true; } return false; } public void Fill(T value) { if (IsEmpty) { return; } if (TryGetSpan(out var span)) { span.Fill(value); return; } for (int i = 0; i < Height; i++) { GetRowSpan(i).Fill(value); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] [EditorBrowsable(EditorBrowsableState.Never)] public unsafe ref T GetPinnableReference() { ref T result = ref Unsafe.AsRef<T>(null); if (Length != 0) { result = ref MemoryMarshal.GetReference(span); } return ref result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReference() { return ref MemoryMarshal.GetReference(span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T DangerousGetReferenceAt(int i, int j) { ref T reference = ref MemoryMarshal.GetReference(span); nint elementOffset = (nint)(uint)i * (nint)(uint)Stride + (nint)(uint)j; return ref Unsafe.Add(ref reference, elementOffset); } public Span2D<T> Slice(int row, int column, int height, int width) { if ((uint)row >= Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } if ((uint)column >= this.width) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } if ((uint)height > Height - row) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForHeight(); } if ((uint)width > this.width - column) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForWidth(); } nint i = (nint)(uint)Stride * (nint)(uint)row + (nint)(uint)column; int pitch = Stride - width; return new Span2D<T>(ref span.DangerousGetReferenceAt(i), height, width, pitch); } public Span<T> GetRowSpan(int row) { if ((uint)row >= (uint)Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } return MemoryMarshal.CreateSpan(ref DangerousGetReferenceAt(row, 0), width); } public bool TryGetSpan(out Span<T> span) { if (Stride == width && Length <= int.MaxValue) { span = MemoryMarshal.CreateSpan(ref MemoryMarshal.GetReference(this.span), (int)Length); return true; } span = default(Span<T>); return false; } public T[,] ToArray() { T[,] array = new T[Height, width]; CopyTo(array.AsSpan()); return array; } [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("Equals() on Span will always throw an exception. Use == instead.")] public override bool Equals(object? obj) { throw new NotSupportedException("Microsoft.Toolkit.HighPerformance.Span2D<T>.Equals(object) is not supported"); } [EditorBrowsable(EditorBrowsableState.Never)] [Obsolete("GetHashCode() on Span will always throw an exception.")] public override int GetHashCode() { throw new NotSupportedException("Microsoft.Toolkit.HighPerformance.Span2D<T>.GetHashCode() is not supported"); } public override string ToString() { return $"Microsoft.Toolkit.HighPerformance.Span2D<{typeof(T)}>[{Height}, {width}]"; } public static bool operator ==(Span2D<T> left, Span2D<T> right) { if (left.span == right.span && left.width == right.width) { return left.Stride == right.Stride; } return false; } public static bool operator !=(Span2D<T> left, Span2D<T> right) { return !(left == right); } public static implicit operator Span2D<T>(T[,]? array) { return new Span2D<T>(array); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public RefEnumerable<T> GetRow(int row) { if ((uint)row >= Height) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForRow(); } nint elementOffset = (nint)(uint)Stride * (nint)(uint)row; return new RefEnumerable<T>(ref Unsafe.Add(ref DangerousGetReference(), elementOffset), Width, 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public RefEnumerable<T> GetColumn(int column) { if ((uint)column >= Width) { ThrowHelper.ThrowArgumentOutOfRangeExceptionForColumn(); } return new RefEnumerable<T>(ref Unsafe.Add(ref DangerousGetReference(), (nint)(uint)column), Height, Stride); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Enumerator GetEnumerator() { return new Enumerator(this); } } public readonly ref struct NullableReadOnlyRef<T> { private readonly ReadOnlySpan<T> span; public static NullableReadOnlyRef<T> Null { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return default(NullableReadOnlyRef<T>); } } public bool HasValue { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { byte b = (byte)span.Length; return b != 0; } } public ref readonly T Value { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (!HasValue) { ThrowInvalidOperationException(); } return ref MemoryMarshal.GetReference(span); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public NullableReadOnlyRef(in T value) { span = MemoryMarshal.CreateReadOnlySpan(in Unsafe.AsRef(in value), 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private NullableReadOnlyRef(ReadOnlySpan<T> span) { this.span = span; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableReadOnlyRef<T>(Ref<T> reference) { return new NullableReadOnlyRef<T>(reference.Span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableReadOnlyRef<T>(ReadOnlyRef<T> reference) { return new NullableReadOnlyRef<T>(reference.Span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableReadOnlyRef<T>(NullableRef<T> reference) { return new NullableReadOnlyRef<T>(reference.Span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator T(NullableReadOnlyRef<T> reference) { return reference.Value; } private static void ThrowInvalidOperationException() { throw new InvalidOperationException("The current instance doesn't have a value that can be accessed"); } } public readonly ref struct NullableRef<T> { internal readonly Span<T> Span; public static NullableRef<T> Null { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return default(NullableRef<T>); } } public bool HasValue { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { byte b = (byte)Span.Length; return b != 0; } } public ref T Value { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { if (!HasValue) { ThrowInvalidOperationException(); } return ref MemoryMarshal.GetReference(Span); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public NullableRef(ref T value) { Span = MemoryMarshal.CreateSpan(ref value, 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] private NullableRef(Span<T> span) { Span = span; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator NullableRef<T>(Ref<T> reference) { return new NullableRef<T>(reference.Span); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static explicit operator T(NullableRef<T> reference) { return reference.Value; } private static void ThrowInvalidOperationException() { throw new InvalidOperationException("The current instance doesn't have a value that can be accessed"); } } public readonly ref struct ReadOnlyRef<T> { internal readonly ReadOnlySpan<T> Span; public ref readonly T Value { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref MemoryMarshal.GetReference(Span); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ReadOnlyRef(in T value) { Span = MemoryMarshal.CreateReadOnlySpan(in Unsafe.AsRef(in value), 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe ReadOnlyRef(void* pointer) : this(in Unsafe.AsRef<T>(pointer)) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator ReadOnlyRef<T>(Ref<T> reference) { return new ReadOnlyRef<T>(in reference.Value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator T(ReadOnlyRef<T> reference) { return reference.Value; } } public readonly ref struct Ref<T> { internal readonly Span<T> Span; public ref T Value { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref MemoryMarshal.GetReference(Span); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Ref(ref T value) { Span = MemoryMarshal.CreateSpan(ref value, 1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public unsafe Ref(void* pointer) : this(ref Unsafe.AsRef<T>(pointer)) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static implicit operator T(Ref<T> reference) { return reference.Value; } } } namespace Microsoft.Toolkit.HighPerformance.Streams { internal sealed class IBufferWriterStream<TWriter> : Stream where TWriter : struct, IBufferWriter<byte> { private readonly TWriter bufferWriter; private bool disposed; public override bool CanRead => false; public override bool CanSeek => false; public override bool CanWrite { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return !disposed; } } public override long Length { get { throw MemoryStream.GetNotSupportedException(); } } public override long Position { get { throw MemoryStream.GetNotSupportedException(); } set { throw MemoryStream.GetNotSupportedException(); } } public IBufferWriterStream(TWriter bufferWriter) { this.bufferWriter = bufferWriter; } public override Task CopyToAsync(Stream destination, int bufferSize, CancellationToken cancellationToken) { throw MemoryStream.GetNotSupportedException(); } public override void Flush() { } public override Task FlushAsync(CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return Task.FromCanceled(cancellationToken); } return Task.CompletedTask; } public override Task<int> ReadAsync(byte[]? buffer, int offset, int count, CancellationToken cancellationToken) { throw MemoryStream.GetNotSupportedException(); } public override Task WriteAsync(byte[]? buffer, int offset, int count, CancellationToken cancellationToken) { if (cancellationToken.IsCancellationRequested) { return Task.FromCanceled(cancellationToken); } try { Write(buffer, offset, count); return Task.CompletedTask; } catch (OperationCanceledException ex) { return Task.FromCanceled(ex.CancellationToken); } catch (Exception exception) { return Task.FromException(exception); } } public override long Seek(long offset, SeekOrigin origin) { throw MemoryStream.GetNotSupportedException(); } public override void SetLength(long value) { throw MemoryStream.GetNotSupportedException(); } public override int Read(byte[]? buffer, int offset, int count) { throw MemoryStream.GetNotSupportedException(); } public override int ReadByte() { throw
Raylib-CsLo.dll
Decompiled 9 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using Microsoft.CodeAnalysis; using Microsoft.Toolkit.HighPerformance; using Microsoft.Toolkit.HighPerformance.Buffers; using Raylib_CsLo.InternalHelpers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NotNotTech")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("(C) NotNotTech and Contribs")] [assembly: AssemblyDescription("\r\n Managed C# bindings to Raylib, a friendly 2d/3d game framework similar to XNA / MonoGame.\r\n - Win/Linux/OsX supported.\r\n - Includes bindings for raylib extras: RayGui, Easings, Physac, RlGl, RayMath.\r\n - Minimal bindings + convenience wrappers to make it easier to use.\r\n - Tested and verified via more than 100 examples (**ALL** Raylib examples ported). These [examples are available to you in the GitHub Repo](https://github.com/NotNotTech/Raylib-CsLo/tree/main/Raylib-CsLo.Examples)\r\n - Requires `unsafe` for 3d workflows.\r\n - Supports net5+, Mono 6.4+, NetCore3.0\r\n - Tested on Win10 Net6. Please test on other platforms and [raise an issue](https://github.com/NotNotTech/Raylib-CsLo/issues) if any problems occur.\r\n - A focus on performance. No runtime allocations if at all possible.\r\n - No intellisense docs. [read the raylib cheatsheet for docs](https://www.raylib.com/cheatsheet/cheatsheet.html) or [view the examples](https://github.com/NotNotTech/Raylib-CsLo/tree/main/Raylib-CsLo.Examples)\r\n ")] [assembly: AssemblyFileVersion("0.0.0.*")] [assembly: AssemblyInformationalVersion("4.2.0.9")] [assembly: AssemblyProduct("Raylib-CsLo")] [assembly: AssemblyTitle("Raylib-CsLo")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NotNotTech/Raylib-CsLo")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.20128")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NativeIntegerAttribute : Attribute { public readonly bool[] TransformFlags; public NativeIntegerAttribute() { TransformFlags = new bool[1] { true }; } public NativeIntegerAttribute(bool[] P_0) { TransformFlags = P_0; } } } namespace Raylib_CsLo { public struct AudioStream { public unsafe rAudioBuffer* buffer; public unsafe rAudioProcessor* processor; public uint sampleRate; public uint sampleSize; public uint channels; } public enum BlendMode { BLEND_ALPHA, BLEND_ADDITIVE, BLEND_MULTIPLIED, BLEND_ADD_COLORS, BLEND_SUBTRACT_COLORS, BLEND_ALPHA_PREMULTIPLY, BLEND_CUSTOM } public struct BoneInfo { public unsafe fixed sbyte name[32]; public int parent; } public struct BoundingBox { public Vector3 min; public Vector3 max; public BoundingBox(Vector3 min, Vector3 max) { this.min = min; this.max = max; } } public struct Camera2D { public Vector2 offset; public Vector2 target; public float rotation; public float zoom; } public struct Camera3D { public Vector3 position; public Vector3 target; public Vector3 up; public float fovy; public int projection; public CameraProjection projection_ { get { return (CameraProjection)projection; } set { projection = (int)value; } } public Camera3D(Vector3 position, Vector3 target, Vector3 up, float fovy, CameraProjection projection) { this.position = position; this.target = target; this.up = up; this.fovy = fovy; this.projection = (int)projection; } } public enum CameraMode { CAMERA_CUSTOM, CAMERA_FREE, CAMERA_ORBITAL, CAMERA_FIRST_PERSON, CAMERA_THIRD_PERSON } public enum CameraProjection { CAMERA_PERSPECTIVE, CAMERA_ORTHOGRAPHIC } public struct Color { public byte r; public byte g; public byte b; public byte a; public Color(byte r, byte g, byte b, byte a) { this.r = r; this.g = g; this.b = b; this.a = a; } public Color(int r, int g, int b, int a) { this.r = (byte)r; this.g = (byte)g; this.b = (byte)b; this.a = (byte)a; } } public enum ConfigFlags { FLAG_VSYNC_HINT = 64, FLAG_FULLSCREEN_MODE = 2, FLAG_WINDOW_RESIZABLE = 4, FLAG_WINDOW_UNDECORATED = 8, FLAG_WINDOW_HIDDEN = 128, FLAG_WINDOW_MINIMIZED = 512, FLAG_WINDOW_MAXIMIZED = 1024, FLAG_WINDOW_UNFOCUSED = 2048, FLAG_WINDOW_TOPMOST = 4096, FLAG_WINDOW_ALWAYS_RUN = 256, FLAG_WINDOW_TRANSPARENT = 16, FLAG_WINDOW_HIGHDPI = 8192, FLAG_WINDOW_MOUSE_PASSTHROUGH = 16384, FLAG_MSAA_4X_HINT = 32, FLAG_INTERLACED_HINT = 65536 } public enum CubemapLayout { CUBEMAP_LAYOUT_AUTO_DETECT, CUBEMAP_LAYOUT_LINE_VERTICAL, CUBEMAP_LAYOUT_LINE_HORIZONTAL, CUBEMAP_LAYOUT_CROSS_THREE_BY_FOUR, CUBEMAP_LAYOUT_CROSS_FOUR_BY_THREE, CUBEMAP_LAYOUT_PANORAMA } public static class Easings { public static float EaseLinearNone(float t, float b, float c, float d) { return c * t / d + b; } public static float EaseLinearIn(float t, float b, float c, float d) { return c * t / d + b; } public static float EaseLinearOut(float t, float b, float c, float d) { return c * t / d + b; } public static float EaseLinearInOut(float t, float b, float c, float d) { return c * t / d + b; } public static float EaseSineIn(float t, float b, float c, float d) { return (0f - c) * MathF.Cos(t / d * (MathF.PI / 2f)) + c + b; } public static float EaseSineOut(float t, float b, float c, float d) { return c * MathF.Sin(t / d * (MathF.PI / 2f)) + b; } public static float EaseSineInOut(float t, float b, float c, float d) { return (0f - c) / 2f * (MathF.Cos(MathF.PI * t / d) - 1f) + b; } public static float EaseCircIn(float t, float b, float c, float d) { t /= d; return (0f - c) * (MathF.Sqrt(1f - t * t) - 1f) + b; } public static float EaseCircOut(float t, float b, float c, float d) { t = t / d - 1f; return c * MathF.Sqrt(1f - t * t) + b; } public static float EaseCircInOut(float t, float b, float c, float d) { if ((t /= d / 2f) < 1f) { return (0f - c) / 2f * (MathF.Sqrt(1f - t * t) - 1f) + b; } t -= 2f; return c / 2f * (MathF.Sqrt(1f - t * t) + 1f) + b; } public static float EaseCubicIn(float t, float b, float c, float d) { t /= d; return c * t * t * t + b; } public static float EaseCubicOut(float t, float b, float c, float d) { t = t / d - 1f; return c * (t * t * t + 1f) + b; } public static float EaseCubicInOut(float t, float b, float c, float d) { if ((t /= d / 2f) < 1f) { return c / 2f * t * t * t + b; } t -= 2f; return c / 2f * (t * t * t + 2f) + b; } public static float EaseQuadIn(float t, float b, float c, float d) { t /= d; return c * t * t + b; } public static float EaseQuadOut(float t, float b, float c, float d) { t /= d; return (0f - c) * t * (t - 2f) + b; } public static float EaseQuadInOut(float t, float b, float c, float d) { if ((t /= d / 2f) < 1f) { return c / 2f * (t * t) + b; } return (0f - c) / 2f * ((t - 1f) * (t - 3f) - 1f) + b; } public static float EaseExpoIn(float t, float b, float c, float d) { if (t != 0f) { return c * MathF.Pow(2f, 10f * (t / d - 1f)) + b; } return b; } public static float EaseExpoOut(float t, float b, float c, float d) { if (t != d) { return c * (0f - MathF.Pow(2f, -10f * t / d) + 1f) + b; } return b + c; } public static float EaseExpoInOut(float t, float b, float c, float d) { if (t == 0f) { return b; } if (t == d) { return b + c; } if ((t /= d / 2f) < 1f) { return c / 2f * MathF.Pow(2f, 10f * (t - 1f)) + b; } return c / 2f * (0f - MathF.Pow(2f, -10f * (t - 1f)) + 2f) + b; } public static float EaseBackIn(float t, float b, float c, float d) { float num = 1.70158f; float num2 = (t /= d); return c * num2 * t * ((num + 1f) * t - num) + b; } public static float EaseBackOut(float t, float b, float c, float d) { float num = 1.70158f; t = t / d - 1f; return c * (t * t * ((num + 1f) * t + num) + 1f) + b; } public static float EaseBackInOut(float t, float b, float c, float d) { float num = 1.70158f; if ((t /= d / 2f) < 1f) { num *= 1.525f; return c / 2f * (t * t * ((num + 1f) * t - num)) + b; } float num2 = (t -= 2f); num *= 1.525f; return c / 2f * (num2 * t * ((num + 1f) * t + num) + 2f) + b; } public static float EaseBounceOut(float t, float b, float c, float d) { if ((t /= d) < 0.36363637f) { return c * (7.5625f * t * t) + b; } if (t < 0.72727275f) { float num = (t -= 0.54545456f); return c * (7.5625f * num * t + 0.75f) + b; } if ((double)t < 0.9090909090909091) { float num2 = (t -= 0.8181818f); return c * (7.5625f * num2 * t + 0.9375f) + b; } float num3 = (t -= 21f / 22f); return c * (7.5625f * num3 * t + 63f / 64f) + b; } public static float EaseBounceIn(float t, float b, float c, float d) { return c - EaseBounceOut(d - t, 0f, c, d) + b; } public static float EaseBounceInOut(float t, float b, float c, float d) { if (t < d / 2f) { return EaseBounceIn(t * 2f, 0f, c, d) * 0.5f + b; } return EaseBounceOut(t * 2f - d, 0f, c, d) * 0.5f + c * 0.5f + b; } public static float EaseElasticIn(float t, float b, float c, float d) { if (t == 0f) { return b; } if ((t /= d) == 1f) { return b + c; } float num = d * 0.3f; float num2 = num / 4f; return 0f - c * MathF.Pow(2f, 10f * (t -= 1f)) * MathF.Sin((t * d - num2) * (MathF.PI * 2f) / num) + b; } public static float EaseElasticOut(float t, float b, float c, float d) { if (t == 0f) { return b; } if ((t /= d) == 1f) { return b + c; } float num = d * 0.3f; float num2 = num / 4f; return c * MathF.Pow(2f, -10f * t) * MathF.Sin((t * d - num2) * (MathF.PI * 2f) / num) + c + b; } public static float EaseElasticInOut(float t, float b, float c, float d) { if (t == 0f) { return b; } if ((t /= d / 2f) == 2f) { return b + c; } float num = d * 0.45000002f; float num2 = num / 4f; if (t < 1f) { float num3 = c * MathF.Pow(2f, 10f * (t -= 1f)); return -0.5f * (num3 * MathF.Sin((t * d - num2) * (MathF.PI * 2f) / num)) + b; } return c * MathF.Pow(2f, -10f * (t -= 1f)) * MathF.Sin((t * d - num2) * (MathF.PI * 2f) / num) * 0.5f + c + b; } } public struct FilePathList { public uint capacity; public uint count; public unsafe sbyte** paths; } public struct float16 { public unsafe fixed float v[16]; public unsafe static float16 FromMatrix(Matrix4x4 matrix) { float16* ptr = (float16*)(&matrix); return *ptr; } } public struct float3 { public unsafe fixed float v[3]; public unsafe static float3 FromVector3(Vector3 vector) { float3* ptr = (float3*)(&vector); return *ptr; } } public struct Font { public int baseSize; public int glyphCount; public int glyphPadding; public Texture texture; public unsafe Rectangle* recs; public unsafe GlyphInfo* glyphs; } public enum FontType { FONT_DEFAULT, FONT_BITMAP, FONT_SDF } public enum GamepadAxis { GAMEPAD_AXIS_LEFT_X, GAMEPAD_AXIS_LEFT_Y, GAMEPAD_AXIS_RIGHT_X, GAMEPAD_AXIS_RIGHT_Y, GAMEPAD_AXIS_LEFT_TRIGGER, GAMEPAD_AXIS_RIGHT_TRIGGER } public enum GamepadButton { GAMEPAD_BUTTON_UNKNOWN, GAMEPAD_BUTTON_LEFT_FACE_UP, GAMEPAD_BUTTON_LEFT_FACE_RIGHT, GAMEPAD_BUTTON_LEFT_FACE_DOWN, GAMEPAD_BUTTON_LEFT_FACE_LEFT, GAMEPAD_BUTTON_RIGHT_FACE_UP, GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, GAMEPAD_BUTTON_RIGHT_FACE_DOWN, GAMEPAD_BUTTON_RIGHT_FACE_LEFT, GAMEPAD_BUTTON_LEFT_TRIGGER_1, GAMEPAD_BUTTON_LEFT_TRIGGER_2, GAMEPAD_BUTTON_RIGHT_TRIGGER_1, GAMEPAD_BUTTON_RIGHT_TRIGGER_2, GAMEPAD_BUTTON_MIDDLE_LEFT, GAMEPAD_BUTTON_MIDDLE, GAMEPAD_BUTTON_MIDDLE_RIGHT, GAMEPAD_BUTTON_LEFT_THUMB, GAMEPAD_BUTTON_RIGHT_THUMB } public enum Gesture { GESTURE_NONE = 0, GESTURE_TAP = 1, GESTURE_DOUBLETAP = 2, GESTURE_HOLD = 4, GESTURE_DRAG = 8, GESTURE_SWIPE_RIGHT = 0x10, GESTURE_SWIPE_LEFT = 0x20, GESTURE_SWIPE_UP = 0x40, GESTURE_SWIPE_DOWN = 0x80, GESTURE_PINCH_IN = 0x100, GESTURE_PINCH_OUT = 0x200 } public struct GlyphInfo { public int value; public int offsetX; public int offsetY; public int advanceX; public Image image; } public enum GuiCheckBoxProperty { CHECK_PADDING = 0x10 } public enum GuiColorPickerProperty { COLOR_SELECTOR_SIZE = 16, HUEBAR_WIDTH, HUEBAR_PADDING, HUEBAR_SELECTOR_HEIGHT, HUEBAR_SELECTOR_OVERFLOW } public enum GuiComboBoxProperty { COMBO_BUTTON_WIDTH = 16, COMBO_BUTTON_SPACING } public enum GuiControl { DEFAULT, LABEL, BUTTON, TOGGLE, SLIDER, PROGRESSBAR, CHECKBOX, COMBOBOX, DROPDOWNBOX, TEXTBOX, VALUEBOX, SPINNER, LISTVIEW, COLORPICKER, SCROLLBAR, STATUSBAR } public enum GuiControlProperty { BORDER_COLOR_NORMAL, BASE_COLOR_NORMAL, TEXT_COLOR_NORMAL, BORDER_COLOR_FOCUSED, BASE_COLOR_FOCUSED, TEXT_COLOR_FOCUSED, BORDER_COLOR_PRESSED, BASE_COLOR_PRESSED, TEXT_COLOR_PRESSED, BORDER_COLOR_DISABLED, BASE_COLOR_DISABLED, TEXT_COLOR_DISABLED, BORDER_WIDTH, TEXT_PADDING, TEXT_ALIGNMENT, RESERVED } public enum GuiDefaultProperty { TEXT_SIZE = 16, TEXT_SPACING, LINE_COLOR, BACKGROUND_COLOR } public enum GuiDropdownBoxProperty { ARROW_PADDING = 16, DROPDOWN_ITEMS_SPACING } public enum GuiIconName { ICON_NONE, ICON_FOLDER_FILE_OPEN, ICON_FILE_SAVE_CLASSIC, ICON_FOLDER_OPEN, ICON_FOLDER_SAVE, ICON_FILE_OPEN, ICON_FILE_SAVE, ICON_FILE_EXPORT, ICON_FILE_ADD, ICON_FILE_DELETE, ICON_FILETYPE_TEXT, ICON_FILETYPE_AUDIO, ICON_FILETYPE_IMAGE, ICON_FILETYPE_PLAY, ICON_FILETYPE_VIDEO, ICON_FILETYPE_INFO, ICON_FILE_COPY, ICON_FILE_CUT, ICON_FILE_PASTE, ICON_CURSOR_HAND, ICON_CURSOR_POINTER, ICON_CURSOR_CLASSIC, ICON_PENCIL, ICON_PENCIL_BIG, ICON_BRUSH_CLASSIC, ICON_BRUSH_PAINTER, ICON_WATER_DROP, ICON_COLOR_PICKER, ICON_RUBBER, ICON_COLOR_BUCKET, ICON_TEXT_T, ICON_TEXT_A, ICON_SCALE, ICON_RESIZE, ICON_FILTER_POINT, ICON_FILTER_BILINEAR, ICON_CROP, ICON_CROP_ALPHA, ICON_SQUARE_TOGGLE, ICON_SYMMETRY, ICON_SYMMETRY_HORIZONTAL, ICON_SYMMETRY_VERTICAL, ICON_LENS, ICON_LENS_BIG, ICON_EYE_ON, ICON_EYE_OFF, ICON_FILTER_TOP, ICON_FILTER, ICON_TARGET_POINT, ICON_TARGET_SMALL, ICON_TARGET_BIG, ICON_TARGET_MOVE, ICON_CURSOR_MOVE, ICON_CURSOR_SCALE, ICON_CURSOR_SCALE_RIGHT, ICON_CURSOR_SCALE_LEFT, ICON_UNDO, ICON_REDO, ICON_REREDO, ICON_MUTATE, ICON_ROTATE, ICON_REPEAT, ICON_SHUFFLE, ICON_EMPTYBOX, ICON_TARGET, ICON_TARGET_SMALL_FILL, ICON_TARGET_BIG_FILL, ICON_TARGET_MOVE_FILL, ICON_CURSOR_MOVE_FILL, ICON_CURSOR_SCALE_FILL, ICON_CURSOR_SCALE_RIGHT_FILL, ICON_CURSOR_SCALE_LEFT_FILL, ICON_UNDO_FILL, ICON_REDO_FILL, ICON_REREDO_FILL, ICON_MUTATE_FILL, ICON_ROTATE_FILL, ICON_REPEAT_FILL, ICON_SHUFFLE_FILL, ICON_EMPTYBOX_SMALL, ICON_BOX, ICON_BOX_TOP, ICON_BOX_TOP_RIGHT, ICON_BOX_RIGHT, ICON_BOX_BOTTOM_RIGHT, ICON_BOX_BOTTOM, ICON_BOX_BOTTOM_LEFT, ICON_BOX_LEFT, ICON_BOX_TOP_LEFT, ICON_BOX_CENTER, ICON_BOX_CIRCLE_MASK, ICON_POT, ICON_ALPHA_MULTIPLY, ICON_ALPHA_CLEAR, ICON_DITHERING, ICON_MIPMAPS, ICON_BOX_GRID, ICON_GRID, ICON_BOX_CORNERS_SMALL, ICON_BOX_CORNERS_BIG, ICON_FOUR_BOXES, ICON_GRID_FILL, ICON_BOX_MULTISIZE, ICON_ZOOM_SMALL, ICON_ZOOM_MEDIUM, ICON_ZOOM_BIG, ICON_ZOOM_ALL, ICON_ZOOM_CENTER, ICON_BOX_DOTS_SMALL, ICON_BOX_DOTS_BIG, ICON_BOX_CONCENTRIC, ICON_BOX_GRID_BIG, ICON_OK_TICK, ICON_CROSS, ICON_ARROW_LEFT, ICON_ARROW_RIGHT, ICON_ARROW_DOWN, ICON_ARROW_UP, ICON_ARROW_LEFT_FILL, ICON_ARROW_RIGHT_FILL, ICON_ARROW_DOWN_FILL, ICON_ARROW_UP_FILL, ICON_AUDIO, ICON_FX, ICON_WAVE, ICON_WAVE_SINUS, ICON_WAVE_SQUARE, ICON_WAVE_TRIANGULAR, ICON_CROSS_SMALL, ICON_PLAYER_PREVIOUS, ICON_PLAYER_PLAY_BACK, ICON_PLAYER_PLAY, ICON_PLAYER_PAUSE, ICON_PLAYER_STOP, ICON_PLAYER_NEXT, ICON_PLAYER_RECORD, ICON_MAGNET, ICON_LOCK_CLOSE, ICON_LOCK_OPEN, ICON_CLOCK, ICON_TOOLS, ICON_GEAR, ICON_GEAR_BIG, ICON_BIN, ICON_HAND_POINTER, ICON_LASER, ICON_COIN, ICON_EXPLOSION, ICON_1UP, ICON_PLAYER, ICON_PLAYER_JUMP, ICON_KEY, ICON_DEMON, ICON_TEXT_POPUP, ICON_GEAR_EX, ICON_CRACK, ICON_CRACK_POINTS, ICON_STAR, ICON_DOOR, ICON_EXIT, ICON_MODE_2D, ICON_MODE_3D, ICON_CUBE, ICON_CUBE_FACE_TOP, ICON_CUBE_FACE_LEFT, ICON_CUBE_FACE_FRONT, ICON_CUBE_FACE_BOTTOM, ICON_CUBE_FACE_RIGHT, ICON_CUBE_FACE_BACK, ICON_CAMERA, ICON_SPECIAL, ICON_LINK_NET, ICON_LINK_BOXES, ICON_LINK_MULTI, ICON_LINK, ICON_LINK_BROKE, ICON_TEXT_NOTES, ICON_NOTEBOOK, ICON_SUITCASE, ICON_SUITCASE_ZIP, ICON_MAILBOX, ICON_MONITOR, ICON_PRINTER, ICON_PHOTO_CAMERA, ICON_PHOTO_CAMERA_FLASH, ICON_HOUSE, ICON_HEART, ICON_CORNER, ICON_VERTICAL_BARS, ICON_VERTICAL_BARS_FILL, ICON_LIFE_BARS, ICON_INFO, ICON_CROSSLINE, ICON_HELP, ICON_FILETYPE_ALPHA, ICON_FILETYPE_HOME, ICON_LAYERS_VISIBLE, ICON_LAYERS, ICON_WINDOW, ICON_HIDPI, ICON_FILETYPE_BINARY, ICON_HEX, ICON_SHIELD, ICON_FILE_NEW, ICON_FOLDER_ADD, ICON_ALARM, ICON_206, ICON_207, ICON_208, ICON_209, ICON_210, ICON_211, ICON_212, ICON_213, ICON_214, ICON_215, ICON_216, ICON_217, ICON_218, ICON_219, ICON_220, ICON_221, ICON_222, ICON_223, ICON_224, ICON_225, ICON_226, ICON_227, ICON_228, ICON_229, ICON_230, ICON_231, ICON_232, ICON_233, ICON_234, ICON_235, ICON_236, ICON_237, ICON_238, ICON_239, ICON_240, ICON_241, ICON_242, ICON_243, ICON_244, ICON_245, ICON_246, ICON_247, ICON_248, ICON_249, ICON_250, ICON_251, ICON_252, ICON_253, ICON_254, ICON_255 } public enum GuiListViewProperty { LIST_ITEMS_HEIGHT = 16, LIST_ITEMS_SPACING, SCROLLBAR_WIDTH, SCROLLBAR_SIDE } public enum GuiProgressBarProperty { PROGRESS_PADDING = 0x10 } public enum GuiScrollBarProperty { ARROWS_SIZE = 16, ARROWS_VISIBLE, SCROLL_SLIDER_PADDING, SCROLL_SLIDER_SIZE, SCROLL_PADDING, SCROLL_SPEED } public enum GuiSliderProperty { SLIDER_WIDTH = 16, SLIDER_PADDING } public enum GuiSpinnerProperty { SPIN_BUTTON_WIDTH = 16, SPIN_BUTTON_SPACING } public enum GuiState { STATE_NORMAL, STATE_FOCUSED, STATE_PRESSED, STATE_DISABLED } public struct GuiStyleProp { public ushort controlId; public ushort propertyId; public uint propertyValue; } public enum GuiTextAlignment { TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER, TEXT_ALIGN_RIGHT } public enum GuiTextBoxProperty { TEXT_INNER_PADDING = 16, TEXT_LINES_SPACING } public enum GuiToggleProperty { GROUP_PADDING = 0x10 } public struct Image { public unsafe void* data; public int width; public int height; public int mipmaps; public int format; } public enum KeyboardKey { KEY_NULL = 0, KEY_APOSTROPHE = 39, KEY_COMMA = 44, KEY_MINUS = 45, KEY_PERIOD = 46, KEY_SLASH = 47, KEY_ZERO = 48, KEY_ONE = 49, KEY_TWO = 50, KEY_THREE = 51, KEY_FOUR = 52, KEY_FIVE = 53, KEY_SIX = 54, KEY_SEVEN = 55, KEY_EIGHT = 56, KEY_NINE = 57, KEY_SEMICOLON = 59, KEY_EQUAL = 61, KEY_A = 65, KEY_B = 66, KEY_C = 67, KEY_D = 68, KEY_E = 69, KEY_F = 70, KEY_G = 71, KEY_H = 72, KEY_I = 73, KEY_J = 74, KEY_K = 75, KEY_L = 76, KEY_M = 77, KEY_N = 78, KEY_O = 79, KEY_P = 80, KEY_Q = 81, KEY_R = 82, KEY_S = 83, KEY_T = 84, KEY_U = 85, KEY_V = 86, KEY_W = 87, KEY_X = 88, KEY_Y = 89, KEY_Z = 90, KEY_LEFT_BRACKET = 91, KEY_BACKSLASH = 92, KEY_RIGHT_BRACKET = 93, KEY_GRAVE = 96, KEY_SPACE = 32, KEY_ESCAPE = 256, KEY_ENTER = 257, KEY_TAB = 258, KEY_BACKSPACE = 259, KEY_INSERT = 260, KEY_DELETE = 261, KEY_RIGHT = 262, KEY_LEFT = 263, KEY_DOWN = 264, KEY_UP = 265, KEY_PAGE_UP = 266, KEY_PAGE_DOWN = 267, KEY_HOME = 268, KEY_END = 269, KEY_CAPS_LOCK = 280, KEY_SCROLL_LOCK = 281, KEY_NUM_LOCK = 282, KEY_PRINT_SCREEN = 283, KEY_PAUSE = 284, KEY_F1 = 290, KEY_F2 = 291, KEY_F3 = 292, KEY_F4 = 293, KEY_F5 = 294, KEY_F6 = 295, KEY_F7 = 296, KEY_F8 = 297, KEY_F9 = 298, KEY_F10 = 299, KEY_F11 = 300, KEY_F12 = 301, KEY_LEFT_SHIFT = 340, KEY_LEFT_CONTROL = 341, KEY_LEFT_ALT = 342, KEY_LEFT_SUPER = 343, KEY_RIGHT_SHIFT = 344, KEY_RIGHT_CONTROL = 345, KEY_RIGHT_ALT = 346, KEY_RIGHT_SUPER = 347, KEY_KB_MENU = 348, KEY_KP_0 = 320, KEY_KP_1 = 321, KEY_KP_2 = 322, KEY_KP_3 = 323, KEY_KP_4 = 324, KEY_KP_5 = 325, KEY_KP_6 = 326, KEY_KP_7 = 327, KEY_KP_8 = 328, KEY_KP_9 = 329, KEY_KP_DECIMAL = 330, KEY_KP_DIVIDE = 331, KEY_KP_MULTIPLY = 332, KEY_KP_SUBTRACT = 333, KEY_KP_ADD = 334, KEY_KP_ENTER = 335, KEY_KP_EQUAL = 336, KEY_BACK = 4, KEY_MENU = 82, KEY_VOLUME_UP = 24, KEY_VOLUME_DOWN = 25 } public struct Material { public Shader shader; public unsafe MaterialMap* maps; public unsafe fixed float @params[4]; } public struct MaterialMap { public Texture texture; public Color color; public float value; } public enum MaterialMapIndex { MATERIAL_MAP_ALBEDO, MATERIAL_MAP_METALNESS, MATERIAL_MAP_NORMAL, MATERIAL_MAP_ROUGHNESS, MATERIAL_MAP_OCCLUSION, MATERIAL_MAP_EMISSION, MATERIAL_MAP_HEIGHT, MATERIAL_MAP_CUBEMAP, MATERIAL_MAP_IRRADIANCE, MATERIAL_MAP_PREFILTER, MATERIAL_MAP_BRDF } public struct Matrix2x2 { public float m00; public float m01; public float m10; public float m11; } public struct Mesh { public int vertexCount; public int triangleCount; public unsafe float* vertices; public unsafe float* texcoords; public unsafe float* texcoords2; public unsafe float* normals; public unsafe float* tangents; public unsafe byte* colors; public unsafe ushort* indices; public unsafe float* animVertices; public unsafe float* animNormals; public unsafe byte* boneIds; public unsafe float* boneWeights; public uint vaoId; public unsafe uint* vboId; } public struct Model { public Matrix4x4 transform; public int meshCount; public int materialCount; public unsafe Mesh* meshes; public unsafe Material* materials; public unsafe int* meshMaterial; public int boneCount; public unsafe BoneInfo* bones; public unsafe Transform* bindPose; } public struct ModelAnimation { public int boneCount; public int frameCount; public unsafe BoneInfo* bones; public unsafe Transform** framePoses; } public enum MouseButton { MOUSE_BUTTON_LEFT, MOUSE_BUTTON_RIGHT, MOUSE_BUTTON_MIDDLE, MOUSE_BUTTON_SIDE, MOUSE_BUTTON_EXTRA, MOUSE_BUTTON_FORWARD, MOUSE_BUTTON_BACK } public enum MouseCursor { MOUSE_CURSOR_DEFAULT, MOUSE_CURSOR_ARROW, MOUSE_CURSOR_IBEAM, MOUSE_CURSOR_CROSSHAIR, MOUSE_CURSOR_POINTING_HAND, MOUSE_CURSOR_RESIZE_EW, MOUSE_CURSOR_RESIZE_NS, MOUSE_CURSOR_RESIZE_NWSE, MOUSE_CURSOR_RESIZE_NESW, MOUSE_CURSOR_RESIZE_ALL, MOUSE_CURSOR_NOT_ALLOWED } public struct Music { public AudioStream stream; public uint frameCount; public Bool looping; public int ctxType; public unsafe void* ctxData; } [AttributeUsage(AttributeTargets.Struct, AllowMultiple = false, Inherited = true)] [Conditional("DEBUG")] internal sealed class NativeInheritanceAttribute : Attribute { private readonly string _name; public string Name => _name; public NativeInheritanceAttribute(string name) { _name = name; } } [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = false, Inherited = true)] [Conditional("DEBUG")] internal sealed class NativeTypeNameAttribute : Attribute { private readonly string _name; public string Name => _name; public NativeTypeNameAttribute(string name) { _name = name; } } public struct NPatchInfo { public Rectangle source; public int left; public int top; public int right; public int bottom; public int layout; public NPatchInfo(Rectangle source, int left, int top, int right, int bottom, NPatchLayout layout) { this.source = source; this.left = left; this.top = top; this.right = right; this.bottom = bottom; this.layout = (int)layout; } } public enum NPatchLayout { NPATCH_NINE_PATCH, NPATCH_THREE_PATCH_VERTICAL, NPATCH_THREE_PATCH_HORIZONTAL } public static class Physac { public const int PHYSAC_MAX_BODIES = 64; public const int PHYSAC_MAX_MANIFOLDS = 4096; public const int PHYSAC_MAX_VERTICES = 24; public const int PHYSAC_DEFAULT_CIRCLE_VERTICES = 24; public const int PHYSAC_COLLISION_ITERATIONS = 100; public const float PHYSAC_PENETRATION_ALLOWANCE = 0.05f; public const float PHYSAC_PENETRATION_CORRECTION = 0.4f; public const float PHYSAC_PI = MathF.PI; public const float PHYSAC_DEG2RAD = MathF.PI / 180f; [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void InitPhysics(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void UpdatePhysics(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void ResetPhysics(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void ClosePhysics(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetPhysicsTimeStep(double delta); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetPhysicsGravity(float x, float y); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern PhysicsBodyData* CreatePhysicsBodyCircle(Vector2 pos, float radius, float density); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern PhysicsBodyData* CreatePhysicsBodyRectangle(Vector2 pos, float width, float height, float density); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern PhysicsBodyData* CreatePhysicsBodyPolygon(Vector2 pos, float radius, int sides, float density); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void DestroyPhysicsBody(PhysicsBodyData* body); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void PhysicsAddForce(PhysicsBodyData* body, Vector2 force); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void PhysicsAddTorque(PhysicsBodyData* body, float amount); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void PhysicsShatter(PhysicsBodyData* body, Vector2 position, float force); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetPhysicsBodyRotation(PhysicsBodyData* body, float radians); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern PhysicsBodyData* GetPhysicsBody(int index); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetPhysicsBodiesCount(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetPhysicsShapeType(int index); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetPhysicsShapeVerticesCount(int index); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Vector2 GetPhysicsShapeVertex(PhysicsBodyData* body, int vertex); } public struct PhysicsBodyData { public uint id; public Bool enabled; public Vector2 position; public Vector2 velocity; public Vector2 force; public float angularVelocity; public float torque; public float orient; public float inertia; public float inverseInertia; public float mass; public float inverseMass; public float staticFriction; public float dynamicFriction; public float restitution; public Bool useGravity; public Bool isGrounded; public Bool freezeOrient; public PhysicsShape shape; } public struct PhysicsManifoldData { public struct _contacts_e__FixedBuffer { public Vector2 e0; public Vector2 e1; public ref Vector2 this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref AsSpan()[index]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span<Vector2> AsSpan() { return MemoryMarshal.CreateSpan(ref e0, 2); } } public uint id; public unsafe PhysicsBodyData* bodyA; public unsafe PhysicsBodyData* bodyB; public float penetration; public Vector2 normal; public _contacts_e__FixedBuffer contacts; public uint contactsCount; public float restitution; public float dynamicFriction; public float staticFriction; } public struct PhysicsShape { public PhysicsShapeType type; public unsafe PhysicsBodyData* body; public PhysicsVertexData vertexData; public float radius; public Matrix2x2 transform; } public enum PhysicsShapeType { PHYSICS_CIRCLE, PHYSICS_POLYGON } public struct PhysicsVertexData { public struct _positions_e__FixedBuffer { public Vector2 e0; public Vector2 e1; public Vector2 e2; public Vector2 e3; public Vector2 e4; public Vector2 e5; public Vector2 e6; public Vector2 e7; public Vector2 e8; public Vector2 e9; public Vector2 e10; public Vector2 e11; public Vector2 e12; public Vector2 e13; public Vector2 e14; public Vector2 e15; public Vector2 e16; public Vector2 e17; public Vector2 e18; public Vector2 e19; public Vector2 e20; public Vector2 e21; public Vector2 e22; public Vector2 e23; public ref Vector2 this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref AsSpan()[index]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span<Vector2> AsSpan() { return MemoryMarshal.CreateSpan(ref e0, 24); } } public struct _normals_e__FixedBuffer { public Vector2 e0; public Vector2 e1; public Vector2 e2; public Vector2 e3; public Vector2 e4; public Vector2 e5; public Vector2 e6; public Vector2 e7; public Vector2 e8; public Vector2 e9; public Vector2 e10; public Vector2 e11; public Vector2 e12; public Vector2 e13; public Vector2 e14; public Vector2 e15; public Vector2 e16; public Vector2 e17; public Vector2 e18; public Vector2 e19; public Vector2 e20; public Vector2 e21; public Vector2 e22; public Vector2 e23; public ref Vector2 this[int index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref AsSpan()[index]; } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public Span<Vector2> AsSpan() { return MemoryMarshal.CreateSpan(ref e0, 24); } } public uint vertexCount; public _positions_e__FixedBuffer positions; public _normals_e__FixedBuffer normals; } public enum PixelFormat { PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1, PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA, PIXELFORMAT_UNCOMPRESSED_R5G6B5, PIXELFORMAT_UNCOMPRESSED_R8G8B8, PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, PIXELFORMAT_UNCOMPRESSED_R4G4B4A4, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, PIXELFORMAT_UNCOMPRESSED_R32, PIXELFORMAT_UNCOMPRESSED_R32G32B32, PIXELFORMAT_UNCOMPRESSED_R32G32B32A32, PIXELFORMAT_COMPRESSED_DXT1_RGB, PIXELFORMAT_COMPRESSED_DXT1_RGBA, PIXELFORMAT_COMPRESSED_DXT3_RGBA, PIXELFORMAT_COMPRESSED_DXT5_RGBA, PIXELFORMAT_COMPRESSED_ETC1_RGB, PIXELFORMAT_COMPRESSED_ETC2_RGB, PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA, PIXELFORMAT_COMPRESSED_PVRT_RGB, PIXELFORMAT_COMPRESSED_PVRT_RGBA, PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA, PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct rAudioBuffer { } [StructLayout(LayoutKind.Sequential, Size = 1)] public struct rAudioProcessor { } public struct Ray { public Vector3 position; public Vector3 direction; public Ray(Vector3 position, Vector3 direction) { this.position = position; this.direction = direction; } } public struct RayCollision { public Bool hit; public float distance; public Vector3 point; public Vector3 normal; } public static class RayGui { public const int SCROLLBAR_LEFT_SIDE = 0; public const int SCROLLBAR_RIGHT_SIDE = 1; public static ReadOnlySpan<byte> RAYGUI_VERSION => "3.2\0"u8; [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiEnable(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiDisable(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiLock(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiUnlock(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool GuiIsLocked(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiFade(float alpha); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiSetState(int state); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GuiGetState(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiSetFont(Font font); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Font GuiGetFont(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiSetStyle(int control, int property, int value); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GuiGetStyle(int control, int property); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiWindowBox(Rectangle bounds, sbyte* title); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiGroupBox(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiLine(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiPanel(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Rectangle GuiScrollPanel(Rectangle bounds, sbyte* text, Rectangle content, Vector2* scroll); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiLabel(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiButton(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiLabelButton(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiToggle(Rectangle bounds, sbyte* text, [MarshalAs(UnmanagedType.U1)] bool active); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GuiToggleGroup(Rectangle bounds, sbyte* text, int active); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiCheckBox(Rectangle bounds, sbyte* text, [MarshalAs(UnmanagedType.U1)] bool @checked); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GuiComboBox(Rectangle bounds, sbyte* text, int active); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiDropdownBox(Rectangle bounds, sbyte* text, int* active, [MarshalAs(UnmanagedType.U1)] bool editMode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiSpinner(Rectangle bounds, sbyte* text, int* value, int minValue, int maxValue, [MarshalAs(UnmanagedType.U1)] bool editMode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiValueBox(Rectangle bounds, sbyte* text, int* value, int minValue, int maxValue, [MarshalAs(UnmanagedType.U1)] bool editMode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiTextBox(Rectangle bounds, sbyte* text, int textSize, [MarshalAs(UnmanagedType.U1)] bool editMode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool GuiTextBoxMulti(Rectangle bounds, sbyte* text, int textSize, [MarshalAs(UnmanagedType.U1)] bool editMode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern float GuiSlider(Rectangle bounds, sbyte* textLeft, sbyte* textRight, float value, float minValue, float maxValue); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern float GuiSliderBar(Rectangle bounds, sbyte* textLeft, sbyte* textRight, float value, float minValue, float maxValue); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern float GuiProgressBar(Rectangle bounds, sbyte* textLeft, sbyte* textRight, float value, float minValue, float maxValue); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiStatusBar(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiDummyRec(Rectangle bounds, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Vector2 GuiGrid(Rectangle bounds, sbyte* text, float spacing, int subdivs); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GuiListView(Rectangle bounds, sbyte* text, int* scrollIndex, int active); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GuiListViewEx(Rectangle bounds, sbyte** text, int count, int* focus, int* scrollIndex, int active); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GuiMessageBox(Rectangle bounds, sbyte* title, sbyte* message, sbyte* buttons); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GuiTextInputBox(Rectangle bounds, sbyte* title, sbyte* message, sbyte* buttons, sbyte* text, int textMaxSize, int* secretViewActive); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Color GuiColorPicker(Rectangle bounds, sbyte* text, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Color GuiColorPanel(Rectangle bounds, sbyte* text, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern float GuiColorBarAlpha(Rectangle bounds, sbyte* text, float alpha); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern float GuiColorBarHue(Rectangle bounds, sbyte* text, float value); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiLoadStyle(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiLoadStyleDefault(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GuiIconText(int iconId, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiDrawIcon(int iconId, int posX, int posY, int pixelSize, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern uint* GuiGetIcons(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern uint* GuiGetIconData(int iconId); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void GuiSetIconData(int iconId, uint* data); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiSetIconScale(uint scale); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiSetIconPixel(int iconId, int x, int y); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void GuiClearIconPixel(int iconId, int x, int y); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool GuiCheckIconPixel(int iconId, int x, int y); public unsafe static bool GuiWindowBox(Rectangle bounds, string? title) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = title.MarshalUtf8(); try { return GuiWindowBox(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static void GuiGroupBox(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { GuiGroupBox(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static void GuiLine(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { GuiLine(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static void GuiLabel(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { GuiLabel(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiButton(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiButton(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiLabelButton(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiLabelButton(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiToggle(Rectangle bounds, string? text, bool active) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiToggle(bounds, spanOwner.AsPtr<sbyte>(), active); } finally { spanOwner.Dispose(); } } public unsafe static int GuiToggleGroup(Rectangle bounds, string? text, int active) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiToggleGroup(bounds, spanOwner.AsPtr<sbyte>(), active); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiCheckBox(Rectangle bounds, string? text, bool @checked) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiCheckBox(bounds, spanOwner.AsPtr<sbyte>(), @checked); } finally { spanOwner.Dispose(); } } public unsafe static int GuiComboBox(Rectangle bounds, string? text, int active) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiComboBox(bounds, spanOwner.AsPtr<sbyte>(), active); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiDropdownBox(Rectangle bounds, string? text, int* active, bool editMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiDropdownBox(bounds, spanOwner.AsPtr<sbyte>(), active, editMode); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiSpinner(Rectangle bounds, string? text, int* value, int minValue, int maxValue, bool editMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiSpinner(bounds, spanOwner.AsPtr<sbyte>(), value, minValue, maxValue, editMode); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiValueBox(Rectangle bounds, string? text, int* value, int minValue, int maxValue, bool editMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiValueBox(bounds, spanOwner.AsPtr<sbyte>(), value, minValue, maxValue, editMode); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiTextBox(Rectangle bounds, string? text, int textSize, bool editMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiTextBox(bounds, spanOwner.AsPtr<sbyte>(), textSize, editMode); } finally { spanOwner.Dispose(); } } public unsafe static bool GuiTextBoxMulti(Rectangle bounds, string? text, int textSize, bool editMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiTextBoxMulti(bounds, spanOwner.AsPtr<sbyte>(), textSize, editMode); } finally { spanOwner.Dispose(); } } public unsafe static float GuiSlider(Rectangle bounds, string? textLeft, string? textRight, float value, float minValue, float maxValue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = textLeft.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner2 = textRight.MarshalUtf8(); try { return GuiSlider(bounds, spanOwner.AsPtr<sbyte>(), spanOwner2.AsPtr<sbyte>(), value, minValue, maxValue); } finally { spanOwner2.Dispose(); } } finally { spanOwner.Dispose(); } } public unsafe static float GuiSliderBar(Rectangle rectangle, string? leftText, string? rightText, float value, float minValue, float maxValue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = leftText.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner2 = rightText.MarshalUtf8(); try { return GuiSliderBar(rectangle, spanOwner.AsPtr<sbyte>(), spanOwner2.AsPtr<sbyte>(), value, minValue, maxValue); } finally { spanOwner2.Dispose(); } } finally { spanOwner.Dispose(); } } public unsafe static float GuiProgressBar(Rectangle bounds, string? textLeft, string? textRight, float value, float minValue, float maxValue) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = textLeft.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner2 = textRight.MarshalUtf8(); try { return GuiProgressBar(bounds, spanOwner.AsPtr<sbyte>(), spanOwner2.AsPtr<sbyte>(), value, minValue, maxValue); } finally { spanOwner2.Dispose(); } } finally { spanOwner.Dispose(); } } public unsafe static void GuiStatusBar(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { GuiStatusBar(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static void GuiDummyRec(Rectangle bounds, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { GuiDummyRec(bounds, spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static int GuiListView(Rectangle bounds, string? text, int* scrollIndex, int active) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return GuiListView(bounds, spanOwner.AsPtr<sbyte>(), scrollIndex, active); } finally { spanOwner.Dispose(); } } public unsafe static int GuiListViewEx(Rectangle bounds, string[] textArray, int count, int* focus, int* scrollIndex, int active) { sbyte** ptr = stackalloc sbyte*[textArray.Length]; for (int i = 0; i < textArray.Length; i++) { ptr[i] = (sbyte*)(void*)Marshal.StringToCoTaskMemUTF8(textArray[i]); } int result = GuiListViewEx(bounds, ptr, count, focus, scrollIndex, active); for (int j = 0; j < textArray.Length; j++) { Marshal.ZeroFreeCoTaskMemUTF8((IntPtr)ptr[j]); } return result; } public unsafe static int GuiMessageBox(Rectangle bounds, string? title, string? message, string? buttons) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = title.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner2 = message.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner3 = buttons.MarshalUtf8(); try { return GuiMessageBox(bounds, spanOwner.AsPtr<sbyte>(), spanOwner2.AsPtr<sbyte>(), spanOwner3.AsPtr<sbyte>()); } finally { spanOwner3.Dispose(); } } finally { spanOwner2.Dispose(); } } finally { spanOwner.Dispose(); } } public unsafe static int GuiTextInputBox(Rectangle bounds, string? title, string? message, string? buttons, string? text, int textMaxSize = 255) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = title.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner2 = message.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner3 = buttons.MarshalUtf8(); try { SpanOwner<sbyte> spanOwner4 = text.MarshalUtf8(); try { return GuiTextInputBox(bounds, spanOwner.AsPtr<sbyte>(), spanOwner2.AsPtr<sbyte>(), spanOwner3.AsPtr<sbyte>(), spanOwner4.AsPtr<sbyte>(), textMaxSize, null); } finally { spanOwner4.Dispose(); } } finally { spanOwner3.Dispose(); } } finally { spanOwner2.Dispose(); } } finally { spanOwner.Dispose(); } } public unsafe static void GuiLoadStyle(string? fileName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = fileName.MarshalUtf8(); try { GuiLoadStyle(spanOwner.AsPtr<sbyte>()); } finally { spanOwner.Dispose(); } } public unsafe static string GuiIconText(int iconId, string? text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) SpanOwner<sbyte> spanOwner = text.MarshalUtf8(); try { return Helpers.Utf8ToString(GuiIconText(iconId, spanOwner.AsPtr<sbyte>())); } finally { spanOwner.Dispose(); } } } public static class Raylib { public static readonly Color LIGHTGRAY = new Color { r = 200, g = 200, b = 200, a = byte.MaxValue }; public static readonly Color GRAY = new Color { r = 130, g = 130, b = 130, a = byte.MaxValue }; public static readonly Color DARKGRAY = new Color { r = 80, g = 80, b = 80, a = byte.MaxValue }; public static readonly Color YELLOW = new Color { r = 253, g = 249, b = 0, a = byte.MaxValue }; public static readonly Color GOLD = new Color { r = byte.MaxValue, g = 203, b = 0, a = byte.MaxValue }; public static readonly Color ORANGE = new Color { r = byte.MaxValue, g = 161, b = 0, a = byte.MaxValue }; public static readonly Color PINK = new Color { r = byte.MaxValue, g = 109, b = 194, a = byte.MaxValue }; public static readonly Color RED = new Color { r = 230, g = 41, b = 55, a = byte.MaxValue }; public static readonly Color MAROON = new Color { r = 190, g = 33, b = 55, a = byte.MaxValue }; public static readonly Color GREEN = new Color { r = 0, g = 228, b = 48, a = byte.MaxValue }; public static readonly Color LIME = new Color { r = 0, g = 158, b = 47, a = byte.MaxValue }; public static readonly Color DARKGREEN = new Color { r = 0, g = 117, b = 44, a = byte.MaxValue }; public static readonly Color SKYBLUE = new Color { r = 102, g = 191, b = byte.MaxValue, a = byte.MaxValue }; public static readonly Color BLUE = new Color { r = 0, g = 121, b = 241, a = byte.MaxValue }; public static readonly Color DARKBLUE = new Color { r = 0, g = 82, b = 172, a = byte.MaxValue }; public static readonly Color PURPLE = new Color { r = 200, g = 122, b = byte.MaxValue, a = byte.MaxValue }; public static readonly Color VIOLET = new Color { r = 135, g = 60, b = 190, a = byte.MaxValue }; public static readonly Color DARKPURPLE = new Color { r = 112, g = 31, b = 126, a = byte.MaxValue }; public static readonly Color BEIGE = new Color { r = 211, g = 176, b = 131, a = byte.MaxValue }; public static readonly Color BROWN = new Color { r = 127, g = 106, b = 79, a = byte.MaxValue }; public static readonly Color DARKBROWN = new Color { r = 76, g = 63, b = 47, a = byte.MaxValue }; public static readonly Color WHITE = new Color { r = byte.MaxValue, g = byte.MaxValue, b = byte.MaxValue, a = byte.MaxValue }; public static readonly Color BLACK = new Color { r = 0, g = 0, b = 0, a = byte.MaxValue }; public static readonly Color BLANK = new Color { r = 0, g = 0, b = 0, a = 0 }; public static readonly Color MAGENTA = new Color { r = byte.MaxValue, g = 0, b = byte.MaxValue, a = byte.MaxValue }; public static readonly Color RAYWHITE = new Color { r = 245, g = 245, b = 245, a = byte.MaxValue }; public const MouseButton MOUSE_LEFT_BUTTON = MouseButton.MOUSE_BUTTON_LEFT; public const MouseButton MOUSE_RIGHT_BUTTON = MouseButton.MOUSE_BUTTON_RIGHT; public const MouseButton MOUSE_MIDDLE_BUTTON = MouseButton.MOUSE_BUTTON_MIDDLE; public const MaterialMapIndex MATERIAL_MAP_DIFFUSE = MaterialMapIndex.MATERIAL_MAP_ALBEDO; public const MaterialMapIndex MATERIAL_MAP_SPECULAR = MaterialMapIndex.MATERIAL_MAP_METALNESS; public const ShaderLocationIndex SHADER_LOC_MAP_DIFFUSE = ShaderLocationIndex.SHADER_LOC_MAP_ALBEDO; public const ShaderLocationIndex SHADER_LOC_MAP_SPECULAR = ShaderLocationIndex.SHADER_LOC_MAP_METALNESS; public static ReadOnlySpan<byte> RAYLIB_VERSION => "4.2\0"u8; [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void InitWindow(int width, int height, sbyte* title); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool WindowShouldClose(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void CloseWindow(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowReady(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowFullscreen(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowHidden(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowMinimized(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowMaximized(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowFocused(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowResized(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsWindowState(uint flag); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowState(uint flags); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void ClearWindowState(uint flags); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void ToggleFullscreen(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void MaximizeWindow(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void MinimizeWindow(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void RestoreWindow(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowIcon(Image image); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetWindowTitle(sbyte* title); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowPosition(int x, int y); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowMonitor(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowMinSize(int width, int height); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowSize(int width, int height); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetWindowOpacity(float opacity); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void* GetWindowHandle(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetScreenWidth(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetScreenHeight(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetRenderWidth(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetRenderHeight(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMonitorCount(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetCurrentMonitor(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetMonitorPosition(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMonitorWidth(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMonitorHeight(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMonitorPhysicalWidth(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMonitorPhysicalHeight(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMonitorRefreshRate(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetWindowPosition(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetWindowScaleDPI(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetMonitorName(int monitor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetClipboardText(sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetClipboardText(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EnableEventWaiting(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DisableEventWaiting(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SwapScreenBuffer(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void PollInputEvents(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void WaitTime(double seconds); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void ShowCursor(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void HideCursor(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsCursorHidden(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EnableCursor(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DisableCursor(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsCursorOnScreen(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void ClearBackground(Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginDrawing(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndDrawing(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginMode2D(Camera2D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndMode2D(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginMode3D(Camera3D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndMode3D(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginTextureMode(RenderTexture target); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndTextureMode(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginShaderMode(Shader shader); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndShaderMode(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginBlendMode(int mode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndBlendMode(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginScissorMode(int x, int y, int width, int height); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndScissorMode(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void BeginVrStereoMode(VrStereoConfig config); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void EndVrStereoMode(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void UnloadVrStereoConfig(VrStereoConfig config); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Shader LoadShader(sbyte* vsFileName, sbyte* fsFileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern Shader LoadShaderFromMemory(sbyte* vsCode, sbyte* fsCode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GetShaderLocation(Shader shader, sbyte* uniformName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GetShaderLocationAttrib(Shader shader, sbyte* attribName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetShaderValue(Shader shader, int locIndex, void* value, int uniformType); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetShaderValueV(Shader shader, int locIndex, void* value, int uniformType, int count); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetShaderValueMatrix(Shader shader, int locIndex, Matrix4x4 mat); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetShaderValueTexture(Shader shader, int locIndex, Texture texture); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void UnloadShader(Shader shader); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Ray GetMouseRay(Vector2 mousePosition, Camera3D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Matrix4x4 GetCameraMatrix(Camera3D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Matrix4x4 GetCameraMatrix2D(Camera2D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetWorldToScreen(Vector3 position, Camera3D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetScreenToWorld2D(Vector2 position, Camera2D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetWorldToScreenEx(Vector3 position, Camera3D camera, int width, int height); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetWorldToScreen2D(Vector2 position, Camera2D camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetTargetFPS(int fps); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetFPS(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern float GetFrameTime(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern double GetTime(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetRandomValue(int min, int max); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetRandomSeed(uint seed); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void TakeScreenshot(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetConfigFlags(uint flags); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void TraceLog(int logLevel, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetTraceLogLevel(int logLevel); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void* MemAlloc(uint size); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void* MemRealloc(void* ptr, uint size); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void MemFree(void* ptr); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void OpenURL(sbyte* url); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetTraceLogCallback(delegate* unmanaged[Cdecl]<int, sbyte*, sbyte*, void> callback); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetLoadFileDataCallback(delegate* unmanaged[Cdecl]<sbyte*, uint*, byte*> callback); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetSaveFileDataCallback(delegate* unmanaged[Cdecl]<sbyte*, void*, uint, Bool> callback); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetLoadFileTextCallback(delegate* unmanaged[Cdecl]<sbyte*, sbyte*> callback); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void SetSaveFileTextCallback(delegate* unmanaged[Cdecl]<sbyte*, sbyte*, Bool> callback); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern byte* LoadFileData(sbyte* fileName, uint* bytesRead); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void UnloadFileData(byte* data); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool SaveFileData(sbyte* fileName, void* data, uint bytesToWrite); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool ExportDataAsCode(sbyte* data, uint size, sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* LoadFileText(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void UnloadFileText(sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool SaveFileText(sbyte* fileName, sbyte* text); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool FileExists(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool DirectoryExists(sbyte* dirPath); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool IsFileExtension(sbyte* fileName, sbyte* ext); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int GetFileLength(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetFileExtension(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetFileName(sbyte* filePath); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetFileNameWithoutExt(sbyte* filePath); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetDirectoryPath(sbyte* filePath); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetPrevDirectoryPath(sbyte* dirPath); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetWorkingDirectory(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetApplicationDirectory(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool ChangeDirectory(sbyte* dir); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public unsafe static extern bool IsPathFile(sbyte* path); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern FilePathList LoadDirectoryFiles(sbyte* dirPath); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern FilePathList LoadDirectoryFilesEx(sbyte* basePath, sbyte* filter, [MarshalAs(UnmanagedType.U1)] bool scanSubdirs); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void UnloadDirectoryFiles(FilePathList files); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsFileDropped(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern FilePathList LoadDroppedFiles(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void UnloadDroppedFiles(FilePathList files); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern nint GetFileModTime(sbyte* fileName); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern byte* CompressData(byte* data, int dataSize, int* compDataSize); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern byte* DecompressData(byte* compData, int compDataSize, int* dataSize); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* EncodeDataBase64(byte* data, int dataSize, int* outputSize); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern byte* DecodeDataBase64(byte* data, int* outputSize); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsKeyPressed(int key); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsKeyDown(int key); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsKeyReleased(int key); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsKeyUp(int key); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetExitKey(int key); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetKeyPressed(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetCharPressed(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsGamepadAvailable(int gamepad); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern sbyte* GetGamepadName(int gamepad); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsGamepadButtonPressed(int gamepad, int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsGamepadButtonDown(int gamepad, int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsGamepadButtonReleased(int gamepad, int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsGamepadButtonUp(int gamepad, int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetGamepadButtonPressed(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetGamepadAxisCount(int gamepad); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern float GetGamepadAxisMovement(int gamepad, int axis); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern int SetGamepadMappings(sbyte* mappings); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsMouseButtonPressed(int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsMouseButtonDown(int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsMouseButtonReleased(int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsMouseButtonUp(int button); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMouseX(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetMouseY(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetMousePosition(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetMouseDelta(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetMousePosition(int x, int y); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetMouseOffset(int offsetX, int offsetY); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetMouseScale(float scaleX, float scaleY); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern float GetMouseWheelMove(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetMouseWheelMoveV(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetMouseCursor(int cursor); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetTouchX(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetTouchY(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetTouchPosition(int index); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetTouchPointId(int index); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetTouchPointCount(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetGesturesEnabled(uint flags); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] [return: MarshalAs(UnmanagedType.U1)] public static extern bool IsGestureDetected(int gesture); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern int GetGestureDetected(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern float GetGestureHoldDuration(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetGestureDragVector(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern float GetGestureDragAngle(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern Vector2 GetGesturePinchVector(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern float GetGesturePinchAngle(); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetCameraMode(Camera3D camera, int mode); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void UpdateCamera(Camera3D* camera); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetCameraPanControl(int keyPan); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetCameraAltControl(int keyAlt); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetCameraSmoothZoomControl(int keySmoothZoom); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetCameraMoveControls(int keyFront, int keyBack, int keyRight, int keyLeft, int keyUp, int keyDown); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void SetShapesTexture(Texture texture, Rectangle source); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawPixel(int posX, int posY, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawPixelV(Vector2 position, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawLineBezierQuad(Vector2 startPos, Vector2 endPos, Vector2 controlPos, float thick, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawLineBezierCubic(Vector2 startPos, Vector2 endPos, Vector2 startControlPos, Vector2 endControlPos, float thick, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public unsafe static extern void DrawLineStrip(Vector2* points, int pointCount, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawCircle(int centerX, int centerY, float radius, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawCircleSector(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawCircleSectorLines(Vector2 center, float radius, float startAngle, float endAngle, int segments, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawCircleV(Vector2 center, float radius, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawCircleLines(int centerX, int centerY, float radius, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawRing(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawRectangle(int posX, int posY, int width, int height, Color color); [DllImport("raylib", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] public static extern void DrawRectangleV(Vector2 position, Vector2 size, Color
System.Runtime.CompilerServices.Unsafe.dll
Decompiled 9 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; [assembly: CLSCompliant(false)] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyFileVersion("5.0.20.51904")] [assembly: AssemblyInformationalVersion("5.0.0")] [assembly: AssemblyTitle("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyDescription("System.Runtime.CompilerServices.Unsafe")] [assembly: AssemblyMetadata(".NETFrameworkAssembly", "")] [assembly: AssemblyMetadata("Serviceable", "True")] [assembly: AssemblyCopyright("© Microsoft Corporation. All rights reserved.")] [assembly: AssemblyCompany("Microsoft Corporation")] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyProduct("Microsoft® .NET Framework")] [assembly: AssemblyVersion("5.0.0.0")] namespace System.Runtime.CompilerServices { public static class Unsafe { [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static T Read<T>(void* source) { return Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static T ReadUnaligned<T>(void* source) { return Unsafe.ReadUnaligned<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static T ReadUnaligned<T>(ref byte source) { return Unsafe.ReadUnaligned<T>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void Write<T>(void* destination, T value) { Unsafe.Write(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void WriteUnaligned<T>(void* destination, T value) { Unsafe.WriteUnaligned(destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void WriteUnaligned<T>(ref byte destination, T value) { Unsafe.WriteUnaligned(ref destination, value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void Copy<T>(void* destination, ref T source) { Unsafe.Write(destination, source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void Copy<T>(ref T destination, void* source) { destination = Unsafe.Read<T>(source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void* AsPointer<T>(ref T value) { return Unsafe.AsPointer(ref value); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void SkipInit<T>(out T value) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static int SizeOf<T>() { return Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void CopyBlock(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void CopyBlock(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlock(ref destination, ref source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void CopyBlockUnaligned(void* destination, void* source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(destination, source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void CopyBlockUnaligned(ref byte destination, ref byte source, uint byteCount) { // IL cpblk instruction Unsafe.CopyBlockUnaligned(ref destination, ref source, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void InitBlock(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void InitBlock(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlock(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void InitBlockUnaligned(void* startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount) { // IL initblk instruction Unsafe.InitBlockUnaligned(ref startAddress, value, byteCount); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static T As<T>(object o) where T : class { return (T)o; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static ref T AsRef<T>(void* source) { return ref *(T*)source; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T AsRef<T>(in T source) { return ref source; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref TTo As<TFrom, TTo>(ref TFrom source) { return ref Unsafe.As<TFrom, TTo>(ref source); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ref T Unbox<T>(object box) { return ref (T)box; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Add<T>(ref T source, int elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void* Add<T>(void* source, int elementOffset) { return (byte*)source + (nint)elementOffset * (nint)Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Add<T>(ref T source, IntPtr elementOffset) { return ref Unsafe.Add(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T AddByteOffset<T>(ref T source, IntPtr byteOffset) { return ref Unsafe.AddByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Subtract<T>(ref T source, int elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static void* Subtract<T>(void* source, int elementOffset) { return (byte*)source - (nint)elementOffset * (nint)Unsafe.SizeOf<T>(); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T Subtract<T>(ref T source, IntPtr elementOffset) { return ref Unsafe.Subtract(ref source, elementOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static ref T SubtractByteOffset<T>(ref T source, IntPtr byteOffset) { return ref Unsafe.SubtractByteOffset(ref source, byteOffset); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static IntPtr ByteOffset<T>(ref T origin, ref T target) { return Unsafe.ByteOffset(target: ref target, origin: ref origin); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static bool AreSame<T>(ref T left, ref T right) { return Unsafe.AreSame(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static bool IsAddressGreaterThan<T>(ref T left, ref T right) { return Unsafe.IsAddressGreaterThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public static bool IsAddressLessThan<T>(ref T left, ref T right) { return Unsafe.IsAddressLessThan(ref left, ref right); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static bool IsNullRef<T>(ref T source) { return Unsafe.AsPointer(ref source) == null; } [MethodImpl(MethodImplOptions.AggressiveInlining)] [System.Runtime.Versioning.NonVersionable] public unsafe static ref T NullRef<T>() { return ref *(T*)null; } } } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method, AllowMultiple = false, Inherited = false)] internal sealed class NonVersionableAttribute : Attribute { } } namespace System.Runtime.CompilerServices { internal sealed class IsReadOnlyAttribute : Attribute { } }