@@ -879,6 +879,7 @@ public MemoryStream GetStream(string tag, byte[] buffer, int offset, int count)
879879 /// <param name="tag">A tag which can be used to track the source of the stream.</param>
880880 /// <param name="buffer">The byte buffer to copy data from.</param>
881881 /// <returns>A <c>MemoryStream</c>.</returns>
882+ [ Obsolete ( "Use the ReadOnlySpan<byte> version of this method instead." ) ]
882883 public MemoryStream GetStream ( Guid id , string tag , Memory < byte > buffer )
883884 {
884885 RecyclableMemoryStream stream = null ;
@@ -896,18 +897,57 @@ public MemoryStream GetStream(Guid id, string tag, Memory<byte> buffer)
896897 }
897898 }
898899
900+ /// <summary>
901+ /// Retrieve a new <c>MemoryStream</c> object with the given tag and with contents copied from the provided
902+ /// buffer. The provided buffer is not wrapped or used after construction.
903+ /// </summary>
904+ /// <remarks>The new stream's position is set to the beginning of the stream when returned.</remarks>
905+ /// <param name="id">A unique identifier which can be used to trace usages of the stream.</param>
906+ /// <param name="tag">A tag which can be used to track the source of the stream.</param>
907+ /// <param name="buffer">The byte buffer to copy data from.</param>
908+ /// <returns>A <c>MemoryStream</c>.</returns>
909+ public MemoryStream GetStream ( Guid id , string tag , ReadOnlySpan < byte > buffer )
910+ {
911+ RecyclableMemoryStream stream = null ;
912+ try
913+ {
914+ stream = new RecyclableMemoryStream ( this , id , tag , buffer . Length ) ;
915+ stream . Write ( buffer ) ;
916+ stream . Position = 0 ;
917+ return stream ;
918+ }
919+ catch
920+ {
921+ stream ? . Dispose ( ) ;
922+ throw ;
923+ }
924+ }
925+
899926 /// <summary>
900927 /// Retrieve a new <c>MemoryStream</c> object with the contents copied from the provided
901928 /// buffer. The provided buffer is not wrapped or used after construction.
902929 /// </summary>
903930 /// <remarks>The new stream's position is set to the beginning of the stream when returned.</remarks>
904931 /// <param name="buffer">The byte buffer to copy data from.</param>
905932 /// <returns>A <c>MemoryStream</c>.</returns>
933+ [ Obsolete ( "Use the ReadOnlySpan<byte> version of this method instead." ) ]
906934 public MemoryStream GetStream ( Memory < byte > buffer )
907935 {
908936 return GetStream ( null , buffer ) ;
909937 }
910938
939+ /// <summary>
940+ /// Retrieve a new <c>MemoryStream</c> object with the contents copied from the provided
941+ /// buffer. The provided buffer is not wrapped or used after construction.
942+ /// </summary>
943+ /// <remarks>The new stream's position is set to the beginning of the stream when returned.</remarks>
944+ /// <param name="buffer">The byte buffer to copy data from.</param>
945+ /// <returns>A <c>MemoryStream</c>.</returns>
946+ public MemoryStream GetStream ( ReadOnlySpan < byte > buffer )
947+ {
948+ return GetStream ( null , buffer ) ;
949+ }
950+
911951 /// <summary>
912952 /// Retrieve a new <c>MemoryStream</c> object with the given tag and with contents copied from the provided
913953 /// buffer. The provided buffer is not wrapped or used after construction.
@@ -916,11 +956,25 @@ public MemoryStream GetStream(Memory<byte> buffer)
916956 /// <param name="tag">A tag which can be used to track the source of the stream.</param>
917957 /// <param name="buffer">The byte buffer to copy data from.</param>
918958 /// <returns>A <c>MemoryStream</c>.</returns>
959+ [ Obsolete ( "Use the ReadOnlySpan<byte> version of this method instead." ) ]
919960 public MemoryStream GetStream ( string tag , Memory < byte > buffer )
920961 {
921962 return GetStream ( Guid . NewGuid ( ) , tag , buffer ) ;
922963 }
923964
965+ /// <summary>
966+ /// Retrieve a new <c>MemoryStream</c> object with the given tag and with contents copied from the provided
967+ /// buffer. The provided buffer is not wrapped or used after construction.
968+ /// </summary>
969+ /// <remarks>The new stream's position is set to the beginning of the stream when returned.</remarks>
970+ /// <param name="tag">A tag which can be used to track the source of the stream.</param>
971+ /// <param name="buffer">The byte buffer to copy data from.</param>
972+ /// <returns>A <c>MemoryStream</c>.</returns>
973+ public MemoryStream GetStream ( string tag , ReadOnlySpan < byte > buffer )
974+ {
975+ return GetStream ( Guid . NewGuid ( ) , tag , buffer ) ;
976+ }
977+
924978 /// <summary>
925979 /// Triggered when a new block is created.
926980 /// </summary>
0 commit comments