diff --git a/Directory.Packages.props b/Directory.Packages.props
index 09060b11..498bf1b5 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -7,6 +7,7 @@
+
@@ -15,4 +16,4 @@
-
+
\ No newline at end of file
diff --git a/src/SharpCompress/BufferPool.cs b/src/SharpCompress/BufferPool.cs
deleted file mode 100644
index 895edc86..00000000
--- a/src/SharpCompress/BufferPool.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Buffers;
-
-namespace SharpCompress.Helpers;
-
-internal static class BufferPool
-{
- ///
- /// gets a buffer from the pool
- ///
- /// size of the buffer
- /// the buffer
- public static byte[] Rent(int bufferSize)
- {
-#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
- return ArrayPool.Shared.Rent(bufferSize);
-#else
- return new byte[bufferSize];
-#endif
- }
-
- ///
- /// returns a buffer to the pool
- ///
- /// the buffer to return
- public static void Return(byte[] buffer)
- {
-#if NETCOREAPP || NETSTANDARD2_1_OR_GREATER
- ArrayPool.Shared.Return(buffer);
-#else
- // no-op
-#endif
- }
-}
diff --git a/src/SharpCompress/Compressors/Rar/RarStream.cs b/src/SharpCompress/Compressors/Rar/RarStream.cs
index bf5d3209..073fcaa0 100644
--- a/src/SharpCompress/Compressors/Rar/RarStream.cs
+++ b/src/SharpCompress/Compressors/Rar/RarStream.cs
@@ -1,6 +1,7 @@
#nullable disable
using System;
+using System.Buffers;
using System.IO;
using SharpCompress.Common.Rar.Headers;
@@ -14,7 +15,7 @@ internal class RarStream : Stream
private bool fetch;
- private byte[] tmpBuffer = BufferPool.Rent(65536);
+ private byte[] tmpBuffer = ArrayPool.Shared.Rent(65536);
private int tmpOffset;
private int tmpCount;
@@ -42,7 +43,7 @@ internal class RarStream : Stream
{
if (disposing)
{
- BufferPool.Return(this.tmpBuffer);
+ ArrayPool.Shared.Return(this.tmpBuffer);
this.tmpBuffer = null;
}
isDisposed = true;
@@ -143,11 +144,11 @@ internal class RarStream : Stream
this.tmpBuffer.Length * 2 > this.tmpCount + count
? this.tmpBuffer.Length * 2
: this.tmpCount + count;
- var newBuffer = BufferPool.Rent(newLength);
+ var newBuffer = ArrayPool.Shared.Rent(newLength);
Buffer.BlockCopy(this.tmpBuffer, 0, newBuffer, 0, this.tmpCount);
var oldBuffer = this.tmpBuffer;
this.tmpBuffer = newBuffer;
- BufferPool.Return(oldBuffer);
+ ArrayPool.Shared.Return(oldBuffer);
}
}
}
diff --git a/src/SharpCompress/SharpCompress.csproj b/src/SharpCompress/SharpCompress.csproj
index 6b31b2a4..4b4909b7 100644
--- a/src/SharpCompress/SharpCompress.csproj
+++ b/src/SharpCompress/SharpCompress.csproj
@@ -33,6 +33,7 @@
true
+
diff --git a/src/SharpCompress/packages.lock.json b/src/SharpCompress/packages.lock.json
index d5c6af0b..3e2da73d 100644
--- a/src/SharpCompress/packages.lock.json
+++ b/src/SharpCompress/packages.lock.json
@@ -30,6 +30,12 @@
"Microsoft.SourceLink.Common": "8.0.0"
}
},
+ "System.Buffers": {
+ "type": "Direct",
+ "requested": "[4.6.0, )",
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
+ },
"System.Memory": {
"type": "Direct",
"requested": "[4.5.5, )",
@@ -76,11 +82,6 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
- "System.Buffers": {
- "type": "Transitive",
- "resolved": "4.5.1",
- "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
- },
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.5.0",
@@ -129,6 +130,12 @@
"Microsoft.NETCore.Platforms": "1.1.0"
}
},
+ "System.Buffers": {
+ "type": "Direct",
+ "requested": "[4.6.0, )",
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
+ },
"System.Memory": {
"type": "Direct",
"requested": "[4.5.5, )",
@@ -175,11 +182,6 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
- "System.Buffers": {
- "type": "Transitive",
- "resolved": "4.5.1",
- "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
- },
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.4.0",
@@ -216,6 +218,12 @@
"Microsoft.SourceLink.Common": "8.0.0"
}
},
+ "System.Buffers": {
+ "type": "Direct",
+ "requested": "[4.6.0, )",
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
+ },
"System.Text.Encoding.CodePages": {
"type": "Direct",
"requested": "[8.0.0, )",
@@ -245,11 +253,6 @@
"resolved": "8.0.0",
"contentHash": "dk9JPxTCIevS75HyEQ0E4OVAFhB2N+V9ShCXf8Q6FkUQZDkgLI12y679Nym1YqsiSysuQskT7Z+6nUf3yab6Vw=="
},
- "System.Buffers": {
- "type": "Transitive",
- "resolved": "4.5.1",
- "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
- },
"System.Numerics.Vectors": {
"type": "Transitive",
"resolved": "4.4.0",
@@ -283,6 +286,12 @@
"Microsoft.SourceLink.Common": "8.0.0"
}
},
+ "System.Buffers": {
+ "type": "Direct",
+ "requested": "[4.6.0, )",
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
+ },
"ZstdSharp.Port": {
"type": "Direct",
"requested": "[0.8.1, )",
@@ -303,9 +312,9 @@
"net8.0": {
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
- "requested": "[8.0.7, )",
- "resolved": "8.0.7",
- "contentHash": "iI52ptEKby2ymQ6B7h4TWbFmm85T4VvLgc/HvS45Yr3lgi4IIFbQtjON3bQbX/Vc94jXNSLvrDOp5Kh7SJyFYQ=="
+ "requested": "[8.0.0, )",
+ "resolved": "8.0.0",
+ "contentHash": "B3etT5XQ2nlWkZGO2m/ytDYrOmSsQG1XNBaM6ZYlX5Ch/tDrMFadr0/mK6gjZwaQc55g+5+WZMw4Cz3m8VEF7g=="
},
"Microsoft.SourceLink.GitHub": {
"type": "Direct",
@@ -317,6 +326,12 @@
"Microsoft.SourceLink.Common": "8.0.0"
}
},
+ "System.Buffers": {
+ "type": "Direct",
+ "requested": "[4.6.0, )",
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
+ },
"ZstdSharp.Port": {
"type": "Direct",
"requested": "[0.8.1, )",
diff --git a/tests/SharpCompress.Test/packages.lock.json b/tests/SharpCompress.Test/packages.lock.json
index 7e146431..d9f5c1eb 100644
--- a/tests/SharpCompress.Test/packages.lock.json
+++ b/tests/SharpCompress.Test/packages.lock.json
@@ -99,8 +99,8 @@
},
"System.Buffers": {
"type": "Transitive",
- "resolved": "4.5.1",
- "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg=="
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
},
"System.Collections.Immutable": {
"type": "Transitive",
@@ -182,6 +182,7 @@
"type": "Project",
"dependencies": {
"Microsoft.Bcl.AsyncInterfaces": "[8.0.0, )",
+ "System.Buffers": "[4.6.0, )",
"System.Memory": "[4.5.5, )",
"System.Text.Encoding.CodePages": "[8.0.0, )",
"ZstdSharp.Port": "[0.8.1, )"
@@ -328,6 +329,11 @@
"resolved": "13.0.1",
"contentHash": "ppPFpBcvxdsfUonNcvITKqLl3bqxWbDCZIzDWHzjpdAHRFfZe0Dw9HmA0+za13IdyrgJwpkDTDA9fHaxOrt20A=="
},
+ "System.Buffers": {
+ "type": "Transitive",
+ "resolved": "4.6.0",
+ "contentHash": "lN6tZi7Q46zFzAbRYXTIvfXcyvQQgxnY7Xm6C6xQ9784dEL1amjM6S6Iw4ZpsvesAKnRVsM4scrDQaDqSClkjA=="
+ },
"System.Configuration.ConfigurationManager": {
"type": "Transitive",
"resolved": "4.4.0",
@@ -394,6 +400,7 @@
"sharpcompress": {
"type": "Project",
"dependencies": {
+ "System.Buffers": "[4.6.0, )",
"ZstdSharp.Port": "[0.8.1, )"
}
},