diff --git a/src/OpenSearch.Net/Transport/PostData.cs b/src/OpenSearch.Net/Transport/PostData.cs index d955f92bfd..16dffb7cbb 100644 --- a/src/OpenSearch.Net/Transport/PostData.cs +++ b/src/OpenSearch.Net/Transport/PostData.cs @@ -46,7 +46,7 @@ public interface IPostData public enum PostType { ByteArray, -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET6_0_OR_GREATER ReadOnlyMemory, #endif LiteralString, @@ -86,7 +86,7 @@ public abstract class PostData public static PostData Bytes(byte[] bytes) => new PostData(bytes); #if NETSTANDARD2_1 || NET6_0_OR_GREATER - public static PostData ReadOnlyMemory(ReadOnlyMemory bytes) => new PostData(bytes.ToArray()); + public static PostData ReadOnlyMemory(ReadOnlyMemory bytes) => new PostData(bytes); #endif public static PostData String(string serializedString) => new PostData(serializedString); @@ -135,7 +135,7 @@ public class PostData : PostData, IPostData private readonly IEnumerable _enumerableOfObject; private readonly IEnumerable _enumerableOfStrings; private readonly string _literalString; -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET6_0_OR_GREATER private readonly ReadOnlyMemory _memoryOfBytes; #endif @@ -145,7 +145,7 @@ protected internal PostData(byte[] item) Type = PostType.ByteArray; } -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET6_0_OR_GREATER protected internal PostData(ReadOnlyMemory item) { _memoryOfBytes = item; @@ -188,7 +188,7 @@ public override void Write(Stream writableStream, IConnectionConfigurationValues buffer = settings.MemoryStreamFactory.Create(WrittenBytes); break; -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET6_0_OR_GREATER case PostType.ReadOnlyMemory: if (_memoryOfBytes.IsEmpty) return; @@ -281,7 +281,7 @@ public override async Task WriteAsync(Stream writableStream, IConnectionConfigur buffer = settings.MemoryStreamFactory.Create(WrittenBytes); break; -#if NETSTANDARD2_1 +#if NETSTANDARD2_1 || NET6_0_OR_GREATER case PostType.ReadOnlyMemory: if (_memoryOfBytes.IsEmpty) return;