diff --git a/Directory.Packages.props b/Directory.Packages.props
index 7559f05e..c09d8026 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -19,5 +19,6 @@
Version="17.14.15"
/>
+
diff --git a/build/packages.lock.json b/build/packages.lock.json
index 8cc0db72..734b855a 100644
--- a/build/packages.lock.json
+++ b/build/packages.lock.json
@@ -52,6 +52,12 @@
"resolved": "13.0.0",
"contentHash": "zcCR1pupa1wI1VqBULRiQKeHKKZOuJhi/K+4V5oO+rHJZlaOD53ViFo1c3PavDoMAfSn/FAXGAWpPoF57rwhYg=="
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
diff --git a/src/SharpCompress/Archives/IArchiveEntryExtensions.cs b/src/SharpCompress/Archives/IArchiveEntryExtensions.cs
index 502a419e..6b6b96b7 100644
--- a/src/SharpCompress/Archives/IArchiveEntryExtensions.cs
+++ b/src/SharpCompress/Archives/IArchiveEntryExtensions.cs
@@ -7,7 +7,7 @@ using SharpCompress.IO;
namespace SharpCompress.Archives;
-public static class IArchiveEntryExtensions
+public static partial class IArchiveEntryExtensions
{
/// The archive entry to extract.
extension(IArchiveEntry archiveEntry)
@@ -16,48 +16,9 @@ public static class IArchiveEntryExtensions
/// Extract entry to the specified stream.
///
/// The stream to write the entry content to.
- /// Optional progress reporter for tracking extraction progress.
- public void WriteTo(Stream streamToWriteTo, IProgress? progress = null) =>
- archiveEntry.WriteTo(streamToWriteTo, bufferSize: null, progress: progress);
-
- ///
- /// Extract entry to the specified stream.
- ///
- /// The stream to write the entry content to.
- /// Options for configuring extraction behavior.
- /// Optional progress reporter for tracking extraction progress.
- public void WriteTo(
- Stream streamToWriteTo,
- ExtractionOptions options,
- IProgress? progress = null
- ) => archiveEntry.WriteTo(streamToWriteTo, options.BufferSize, options, progress);
-
- private void WriteTo(
- Stream streamToWriteTo,
- int? bufferSize,
- ExtractionOptions? options = null,
- IProgress? progress = null
- )
- {
- if (archiveEntry.IsDirectory)
- {
- throw new ExtractionException("Entry is a file directory and cannot be extracted.");
- }
-
- using var entryStream = archiveEntry.OpenEntryStream();
- var checkedStream = options is null
- ? entryStream
- : IEntryExtensions.WrapWithChecksumValidation(archiveEntry, entryStream, options);
- var sourceStream = WrapWithProgress(checkedStream, archiveEntry, progress);
- sourceStream.CopyTo(streamToWriteTo, bufferSize ?? Constants.BufferSize);
- }
-
- ///
- /// Extract entry to the specified stream asynchronously.
- ///
- /// The stream to write the entry content to.
/// Cancellation token.
/// Optional progress reporter for tracking extraction progress.
+ [Zomp.SyncMethodGenerator.CreateSyncVersion(PreserveProgress = true)]
public async ValueTask WriteToAsync(
Stream streamToWriteTo,
IProgress? progress = null,
@@ -73,12 +34,13 @@ public static class IArchiveEntryExtensions
.ConfigureAwait(false);
///
- /// Extract entry to the specified stream asynchronously.
+ /// Extract entry to the specified stream.
///
/// The stream to write the entry content to.
/// Options for configuring extraction behavior.
/// Optional progress reporter for tracking extraction progress.
/// Cancellation token.
+ [Zomp.SyncMethodGenerator.CreateSyncVersion(PreserveProgress = true)]
public async ValueTask WriteToAsync(
Stream streamToWriteTo,
ExtractionOptions options,
@@ -95,6 +57,7 @@ public static class IArchiveEntryExtensions
)
.ConfigureAwait(false);
+ [Zomp.SyncMethodGenerator.CreateSyncVersion(PreserveProgress = true)]
private async ValueTask WriteToAsync(
Stream streamToWriteTo,
int? bufferSize,
@@ -167,19 +130,7 @@ public static class IArchiveEntryExtensions
///
/// Extract to specific directory, retaining filename
///
- public void WriteToDirectory(
- string destinationDirectory,
- ExtractionOptions? options = null
- ) =>
- entry.WriteEntryToDirectory(
- destinationDirectory,
- options,
- (path) => entry.WriteToFile(path, options)
- );
-
- ///
- /// Extract to specific directory asynchronously, retaining filename
- ///
+ [Zomp.SyncMethodGenerator.CreateSyncVersion]
public async ValueTask WriteToDirectoryAsync(
string destinationDirectory,
ExtractionOptions? options = null,
@@ -198,23 +149,7 @@ public static class IArchiveEntryExtensions
///
/// Extract to specific file
///
- public void WriteToFile(string destinationFileName, ExtractionOptions? options = null)
- {
- options ??= new ExtractionOptions();
- entry.WriteEntryToFile(
- destinationFileName,
- options,
- (x, fm) =>
- {
- using var fs = File.Open(x, fm);
- entry.WriteTo(fs, options?.BufferSize ?? Constants.BufferSize, options, null);
- }
- );
- }
-
- ///
- /// Extract to specific file asynchronously
- ///
+ [Zomp.SyncMethodGenerator.CreateSyncVersion]
public async ValueTask WriteToFileAsync(
string destinationFileName,
ExtractionOptions? options = null,
diff --git a/src/SharpCompress/packages.lock.json b/src/SharpCompress/packages.lock.json
index 54571844..8d592036 100644
--- a/src/SharpCompress/packages.lock.json
+++ b/src/SharpCompress/packages.lock.json
@@ -53,6 +53,12 @@
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
@@ -175,6 +181,12 @@
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
@@ -289,6 +301,12 @@
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
}
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
@@ -357,6 +375,12 @@
"resolved": "1.16.0",
"contentHash": "3kdIIceBPumwjw279FuiVMfVENT2cGASXJgcigdySsbX2dJB8ofUgG6i47yqF/k1qu6fvNR3csrSekZPviR6kQ=="
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
@@ -414,6 +438,12 @@
"resolved": "1.16.0",
"contentHash": "3kdIIceBPumwjw279FuiVMfVENT2cGASXJgcigdySsbX2dJB8ofUgG6i47yqF/k1qu6fvNR3csrSekZPviR6kQ=="
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
@@ -477,6 +507,12 @@
"resolved": "1.16.0",
"contentHash": "3kdIIceBPumwjw279FuiVMfVENT2cGASXJgcigdySsbX2dJB8ofUgG6i47yqF/k1qu6fvNR3csrSekZPviR6kQ=="
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
diff --git a/tests/SharpCompress.AotSmoke/packages.lock.json b/tests/SharpCompress.AotSmoke/packages.lock.json
index 19031145..7016eb4f 100644
--- a/tests/SharpCompress.AotSmoke/packages.lock.json
+++ b/tests/SharpCompress.AotSmoke/packages.lock.json
@@ -46,6 +46,12 @@
"resolved": "1.16.0",
"contentHash": "3kdIIceBPumwjw279FuiVMfVENT2cGASXJgcigdySsbX2dJB8ofUgG6i47yqF/k1qu6fvNR3csrSekZPviR6kQ=="
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.300",
diff --git a/tests/SharpCompress.Performance/packages.lock.json b/tests/SharpCompress.Performance/packages.lock.json
index 739ca4c7..47481ccf 100644
--- a/tests/SharpCompress.Performance/packages.lock.json
+++ b/tests/SharpCompress.Performance/packages.lock.json
@@ -62,6 +62,12 @@
"resolved": "1.16.0",
"contentHash": "3kdIIceBPumwjw279FuiVMfVENT2cGASXJgcigdySsbX2dJB8ofUgG6i47yqF/k1qu6fvNR3csrSekZPviR6kQ=="
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"BenchmarkDotNet.Annotations": {
"type": "Transitive",
"resolved": "0.15.8",
diff --git a/tests/SharpCompress.Test/packages.lock.json b/tests/SharpCompress.Test/packages.lock.json
index 2f685ff1..d1e626ce 100644
--- a/tests/SharpCompress.Test/packages.lock.json
+++ b/tests/SharpCompress.Test/packages.lock.json
@@ -70,6 +70,12 @@
"xunit.v3.mtp-v1": "[3.2.2]"
}
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.ApplicationInsights": {
"type": "Transitive",
"resolved": "2.23.0",
@@ -392,6 +398,12 @@
"xunit.v3.mtp-v1": "[3.2.2]"
}
},
+ "Zomp.SyncMethodGenerator": {
+ "type": "Direct",
+ "requested": "[2.0.40, )",
+ "resolved": "2.0.40",
+ "contentHash": "lpU06HVF3AXHHU+qQSmoCCYPf3QfAUD4tePJ6o2PZta0K1Vt2jEyChwEeqTuG1940SB7kT6Wp5BagmL+7ILimw=="
+ },
"Microsoft.ApplicationInsights": {
"type": "Transitive",
"resolved": "2.23.0",