From 59fdef032ae7ddab43d783c385685fb9b0dd8128 Mon Sep 17 00:00:00 2001 From: Sewer 56 Date: Wed, 6 Jul 2022 15:22:44 +0100 Subject: [PATCH] Added: StructArray Span Overloads & BackCompat Overloads --- .../PublicAPI/net5.0/PublicAPI.Shipped.txt | 29 ++- .../PublicAPI/net5.0/PublicAPI.Unshipped.txt | 6 - .../PublicAPI/net6.0/PublicAPI.Shipped.txt | 29 ++- .../PublicAPI/net6.0/PublicAPI.Unshipped.txt | 6 - .../netstandard2.0/PublicAPI.Shipped.txt | 29 ++- .../netstandard2.0/PublicAPI.Unshipped.txt | 6 - .../netstandard2.1/PublicAPI.Shipped.txt | 29 ++- .../netstandard2.1/PublicAPI.Unshipped.txt | 6 - Source/Reloaded.Memory/StructArray.cs | 171 +++++++++++++++++- 9 files changed, 247 insertions(+), 64 deletions(-) diff --git a/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Shipped.txt b/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Shipped.txt index 9865768..a57270e 100644 --- a/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Shipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Shipped.txt @@ -602,13 +602,6 @@ static Reloaded.Memory.Struct.Source.set -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, Reloaded.Memory.Sources.MemoryExtensions.WriteFunction writeFunction, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, T item, bool marshalElement = false) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length = 0, int startIndex = 0) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length = 0) -> void static Reloaded.Memory.StructArray.FromPtr(nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) -> void static Reloaded.Memory.StructArray.GetBytes(T[] items) -> byte[] static Reloaded.Memory.StructArray.GetBytes(T[] items, bool marshalElements) -> byte[] @@ -624,4 +617,24 @@ static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marsha static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file +static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Unshipped.txt b/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Unshipped.txt index 8ada0c0..e69de29 100644 --- a/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Unshipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/net5.0/PublicAPI.Unshipped.txt @@ -1,6 +0,0 @@ -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Shipped.txt b/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Shipped.txt index 9865768..a57270e 100644 --- a/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Shipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Shipped.txt @@ -602,13 +602,6 @@ static Reloaded.Memory.Struct.Source.set -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, Reloaded.Memory.Sources.MemoryExtensions.WriteFunction writeFunction, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, T item, bool marshalElement = false) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length = 0, int startIndex = 0) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length = 0) -> void static Reloaded.Memory.StructArray.FromPtr(nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) -> void static Reloaded.Memory.StructArray.GetBytes(T[] items) -> byte[] static Reloaded.Memory.StructArray.GetBytes(T[] items, bool marshalElements) -> byte[] @@ -624,4 +617,24 @@ static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marsha static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file +static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Unshipped.txt b/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Unshipped.txt index 8ada0c0..e69de29 100644 --- a/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Unshipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/net6.0/PublicAPI.Unshipped.txt @@ -1,6 +0,0 @@ -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt b/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt index 8bde0c9..d10f977 100644 --- a/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Shipped.txt @@ -601,13 +601,6 @@ static Reloaded.Memory.Struct.Source.set -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, Reloaded.Memory.Sources.MemoryExtensions.WriteFunction writeFunction, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, T item, bool marshalElement = false) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length = 0, int startIndex = 0) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length = 0) -> void static Reloaded.Memory.StructArray.FromPtr(nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) -> void static Reloaded.Memory.StructArray.GetBytes(T[] items) -> byte[] static Reloaded.Memory.StructArray.GetBytes(T[] items, bool marshalElements) -> byte[] @@ -623,4 +616,24 @@ static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marsha static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file +static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 8ada0c0..e69de29 100644 --- a/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -1,6 +0,0 @@ -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Shipped.txt b/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Shipped.txt index 9865768..a57270e 100644 --- a/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Shipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Shipped.txt @@ -602,13 +602,6 @@ static Reloaded.Memory.Struct.Source.set -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, ref T item, Reloaded.Memory.Sources.MemoryExtensions.WriteFunction writeFunction, bool marshalElement = false) -> void static Reloaded.Memory.Struct.ToPtr(nuint pointer, T item, bool marshalElement = false) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length = 0, int startIndex = 0) -> void -static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex = 0, int length = 0) -> void -static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length = 0) -> void static Reloaded.Memory.StructArray.FromPtr(nuint memoryAddress, out T[] value, int arrayLength, bool marshal = false) -> void static Reloaded.Memory.StructArray.GetBytes(T[] items) -> byte[] static Reloaded.Memory.StructArray.GetBytes(T[] items, bool marshalElements) -> byte[] @@ -624,4 +617,24 @@ static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marsha static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file +static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, bool marshalElement, int length, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArray(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianPrimitive(System.Span data, out T[] value, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex, int length) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value) -> void +static Reloaded.Memory.StructArray.FromArrayBigEndianStruct(System.Span data, out T[] value, int length) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt b/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt index 8ada0c0..e69de29 100644 --- a/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt +++ b/Source/Reloaded.Memory/PublicAPI/netstandard2.1/PublicAPI.Unshipped.txt @@ -1,6 +0,0 @@ -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, bool marshalElement, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(byte[] data, out T value, int startIndex) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement) -> void -static Reloaded.Memory.Struct.FromArray(System.Span data, out T value, bool marshalElement, int startIndex) -> void \ No newline at end of file diff --git a/Source/Reloaded.Memory/StructArray.cs b/Source/Reloaded.Memory/StructArray.cs index b7e66fa..03d13d2 100644 --- a/Source/Reloaded.Memory/StructArray.cs +++ b/Source/Reloaded.Memory/StructArray.cs @@ -76,8 +76,55 @@ public static void FromArray< #if NET5_0_OR_GREATER [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] #endif - T>(byte[] data, out T[] value, bool marshalElement, int length = 0, - int startIndex = 0) + T>(byte[] data, out T[] value, bool marshalElement, int length, int startIndex) + { + FromArray(data.AsSpan(), out value, marshalElement, length, startIndex); + } + + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// A byte array containing data from which to extract a structure from. + /// Local variable to receive the read in struct array. + /// Set to true to marshal the element. + /// The amount of elements to read from the byte array. + public static void FromArray< +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] +#endif + T>(byte[] data, out T[] value, bool marshalElement, int length) + { + FromArray(data.AsSpan(), out value, marshalElement, length, startIndex: 0); + } + + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// A byte array containing data from which to extract a structure from. + /// Local variable to receive the read in struct array. + /// Set to true to marshal the element. + public static void FromArray< +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] +#endif + T>(byte[] data, out T[] value, bool marshalElement) + { + FromArray(data.AsSpan(), out value, marshalElement, length: 0, startIndex: 0); + } + + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// A byte array containing data from which to extract a structure from. + /// Local variable to receive the read in struct array. + /// Set to true to marshal the element. + /// The amount of elements to read from the byte array. + /// The index in the byte array to read the element(s) from. + public static void FromArray< +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] +#endif + T>(Span data, out T[] value, bool marshalElement, int length, int startIndex) { int structSize = Struct.GetSize(marshalElement); int structureCount = (length == 0) ? (data.Length - startIndex) / structSize : length; @@ -91,6 +138,37 @@ public static void FromArray< } } + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// A byte array containing data from which to extract a structure from. + /// Local variable to receive the read in struct array. + /// Set to true to marshal the element. + /// The amount of elements to read from the byte array. + public static void FromArray< +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] +#endif + T>(Span data, out T[] value, bool marshalElement, int length) + { + FromArray(data, out value, marshalElement, length, startIndex: 0); + } + + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// A byte array containing data from which to extract a structure from. + /// Local variable to receive the read in struct array. + /// Set to true to marshal the element. + public static void FromArray< +#if NET5_0_OR_GREATER + [DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)] +#endif + T>(Span data, out T[] value, bool marshalElement) + { + FromArray(data, out value, marshalElement, length: 0, startIndex: 0); + } + /// /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. /// @@ -98,7 +176,7 @@ public static void FromArray< /// A byte array containing data from which to extract a structure from. /// The index in the byte array to read the element(s) from. /// The amount of elements to read from the byte array. - public static void FromArray(byte[] data, out T[] value, int startIndex = 0, int length = 0) where T : unmanaged + public static void FromArray(byte[] data, out T[] value, int startIndex, int length) where T : unmanaged { int structSize = Struct.GetSize(); int structureCount = (length == 0) ? (data.Length - startIndex) / structSize : length; @@ -116,13 +194,34 @@ public static void FromArray(byte[] data, out T[] value, int startIndex = 0, } } + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + /// The index in the byte array to read the element(s) from. + public static void FromArray(byte[] data, out T[] value, int startIndex) where T : unmanaged + { + FromArray(data, out value, startIndex, length: 0); + } + + /// + /// Converts a byte array to a specified structure or class type with explicit StructLayout attribute. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + public static void FromArray(byte[] data, out T[] value) where T : unmanaged + { + FromArray(data, out value, startIndex: 0, length: 0); + } + /// /// Converts a span to a specified structure or class type with explicit StructLayout attribute. /// /// Local variable to receive the read in struct array. /// A byte array containing data from which to extract a structure from. /// The amount of elements to read from the span. - public static void FromArray(Span data, out T[] value, int length = 0) where T : unmanaged + public static void FromArray(Span data, out T[] value, int length) where T : unmanaged { int structSize = Struct.GetSize(); int structureCount = (length == 0) ? (data.Length) / structSize : length; @@ -139,6 +238,16 @@ public static void FromArray(Span data, out T[] value, int length = 0) } } + /// + /// Converts a span to a specified structure or class type with explicit StructLayout attribute. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + public static void FromArray(Span data, out T[] value) where T : unmanaged + { + FromArray(data, out value, length: 0); + } + /// /// Converts a byte array to a specified Big Endian primitive. /// @@ -146,26 +255,54 @@ public static void FromArray(Span data, out T[] value, int length = 0) /// A byte array containing data from which to extract a structure from. /// The index in the byte array to read the element(s) from. /// The amount of elements to read from the byte array. - public static void FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex = 0, int length = 0) where T : unmanaged + public static void FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex, int length) where T : unmanaged { FromArray(data, out value, startIndex, length); for (int x = 0; x < value.Length; x++) Endian.Reverse(ref value[x], out value[x]); } + /// + /// Converts a byte array to a specified Big Endian primitive. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + /// The index in the byte array to read the element(s) from. + public static void FromArrayBigEndianPrimitive(byte[] data, out T[] value, int startIndex) where T : unmanaged + { + FromArrayBigEndianPrimitive(data, out value, startIndex, length: 0); + } + + /// + /// Converts a byte array to a specified Big Endian primitive. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + public static void FromArrayBigEndianPrimitive(byte[] data, out T[] value) where T : unmanaged + { + FromArrayBigEndianPrimitive(data, out value, startIndex: 0, length: 0); + } + /// /// Converts a span to a specified Big Endian primitive. /// /// Local variable to receive the read in struct array. /// A byte array containing data from which to extract a structure from. /// The amount of elements to read from the span. - public static void FromArrayBigEndianPrimitive(Span data, out T[] value, int length = 0) where T : unmanaged + public static void FromArrayBigEndianPrimitive(Span data, out T[] value, int length) where T : unmanaged { FromArray(data, out value, length); for (int x = 0; x < value.Length; x++) Endian.Reverse(ref value[x], out value[x]); } + /// + /// Converts a span to a specified Big Endian primitive. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + public static void FromArrayBigEndianPrimitive(Span data, out T[] value) where T : unmanaged => FromArrayBigEndianPrimitive(data, out value, length: 0); + /// /// Converts a byte array to a specified Big Endian structure or class type with explicit StructLayout attribute and . /// @@ -173,26 +310,44 @@ public static void FromArrayBigEndianPrimitive(Span data, out T[] value /// A byte array containing data from which to extract a structure from. /// The index in the byte array to read the element(s) from. /// The amount of elements to read from the byte array. - public static void FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex = 0, int length = 0) where T : unmanaged, IEndianReversible + public static void FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex, int length) where T : unmanaged, IEndianReversible { FromArray(data, out value, startIndex, length); for (int x = 0; x < value.Length; x++) value[x].SwapEndian(); } + /// + /// Converts a byte array to a specified Big Endian structure or class type with explicit StructLayout attribute and . + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + /// The index in the byte array to read the element(s) from. + public static void FromArrayBigEndianStruct(byte[] data, out T[] value, int startIndex) where T : unmanaged, IEndianReversible + { + FromArrayBigEndianStruct(data, out value, startIndex, length: 0); + } + /// /// Converts a span to a specified Big Endian structure or class type with explicit StructLayout attribute and .. /// /// Local variable to receive the read in struct array. /// A byte array containing data from which to extract a structure from. /// The amount of elements to read from the span. - public static void FromArrayBigEndianStruct(Span data, out T[] value, int length = 0) where T : unmanaged, IEndianReversible + public static void FromArrayBigEndianStruct(Span data, out T[] value, int length) where T : unmanaged, IEndianReversible { FromArray(data, out value, length); for (int x = 0; x < value.Length; x++) value[x].SwapEndian(); } + /// + /// Converts a span to a specified Big Endian structure or class type with explicit StructLayout attribute and .. + /// + /// Local variable to receive the read in struct array. + /// A byte array containing data from which to extract a structure from. + public static void FromArrayBigEndianStruct(Span data, out T[] value) where T : unmanaged, IEndianReversible => FromArrayBigEndianStruct(data, out value, length: 0); + /// /// Returns the size of a specific primitive or struct type. ///