Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/nuget-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ jobs:
# Build and test
- name: Build and Test
run: dotnet run --project build/build.csproj

- name: Validate AOT Smoke Test
if: matrix.os == 'ubuntu-latest'
run: |
dotnet publish tests/SharpCompress.AotSmoke/SharpCompress.AotSmoke.csproj --configuration Release --runtime linux-x64 --self-contained true --output artifacts/aot-smoke
./artifacts/aot-smoke/SharpCompress.AotSmoke

# Upload artifacts for verification
- name: Upload NuGet Package
Expand Down
12 changes: 6 additions & 6 deletions src/SharpCompress/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@
"net10.0": {
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[10.0.6, )",
"resolved": "10.0.6",
"contentHash": "QKuvS0LWX4fjFqeDkyM7Kqt8P3wYTiPD4nwU+9y59n0sCiG714fxDgbbN82vDnzq89AF/PiHl92TP2C4aFDUQA=="
"requested": "[10.0.8, )",
"resolved": "10.0.8",
"contentHash": "dVbSXGIFNR5nZcv2tOLoWI+a9T4jtFd77IYjuND+QVe360qWgAF7H0WtoopYhRw/+SgpGUTyrkrh+65+ClNnfw=="
},
"Microsoft.NETFramework.ReferenceAssemblies": {
"type": "Direct",
Expand Down Expand Up @@ -388,9 +388,9 @@
"net8.0": {
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[8.0.26, )",
"resolved": "8.0.26",
"contentHash": "o7/yVssM2r9Wyln2s9edBd5ANZXqdSdBI+g7JqXkyJmXrhs2WsJp25K5yPnYrTgdKBCjKB8bg+O2oew4sgzFaA=="
"requested": "[8.0.27, )",
"resolved": "8.0.27",
"contentHash": "rQi9TxifHRnXP7lVRZH05DxD2/XGbJp12q0ozcbrlBlBnyyzssFTH/2vLhtKWUp2CT1qVscTrcYTFiwTyKPKRg=="
},
"Microsoft.NETFramework.ReferenceAssemblies": {
"type": "Direct",
Expand Down
59 changes: 59 additions & 0 deletions tests/SharpCompress.AotSmoke/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System;
using System.IO;
using System.Text;
using SharpCompress.Archives;
using SharpCompress.Common;
using SharpCompress.Readers;
using SharpCompress.Writers;

var original = "SharpCompress AOT smoke test";
using var archiveStream = new MemoryStream();

using (
var writer = WriterFactory.OpenWriter(
archiveStream,
ArchiveType.Zip,
new WriterOptions(CompressionType.Deflate) { LeaveStreamOpen = true }
)
)
{
using var entryStream = new MemoryStream(Encoding.UTF8.GetBytes(original));
writer.Write("payload.txt", entryStream, DateTime.UtcNow);
}

archiveStream.Position = 0;
using (var reader = ReaderFactory.OpenReader(archiveStream, ReaderOptions.ForExternalStream))
{
if (!reader.MoveToNextEntry() || reader.Entry.IsDirectory)
{
throw new InvalidOperationException("Expected a file entry.");
}

using var extracted = new MemoryStream();
reader.WriteEntryTo(extracted);
var actual = Encoding.UTF8.GetString(extracted.ToArray());
if (!string.Equals(original, actual, StringComparison.Ordinal))
{
throw new InvalidOperationException("ReaderFactory round-trip content mismatch.");
}
}

archiveStream.Position = 0;
using (var archive = ArchiveFactory.OpenArchive(archiveStream, ReaderOptions.ForExternalStream))
{
var entryCount = 0;
foreach (var entry in archive.Entries)
{
if (!entry.IsDirectory)
{
entryCount++;
}
}

if (entryCount != 1)
{
throw new InvalidOperationException("ArchiveFactory did not see the expected entry.");
}
}

Console.WriteLine("SharpCompress AOT smoke test passed.");
12 changes: 12 additions & 0 deletions tests/SharpCompress.AotSmoke/SharpCompress.AotSmoke.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<PublishAot>true</PublishAot>
<PublishTrimmed>true</PublishTrimmed>
<TrimMode>full</TrimMode>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\SharpCompress\SharpCompress.csproj" />
</ItemGroup>
</Project>
84 changes: 84 additions & 0 deletions tests/SharpCompress.AotSmoke/packages.lock.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"version": 2,
"dependencies": {
"net10.0": {
"Microsoft.DotNet.ILCompiler": {
"type": "Direct",
"requested": "[10.0.6, )",
"resolved": "10.0.6",
"contentHash": "nBOzxOys8OeyJ+Nsi/uYlI/5TSsvwjaM/p5m4dTL6khCLx9UuP3b2ec3HeuBw/+F7hHCAZG1yFx8VBeoRAX+EQ=="
},
"Microsoft.NET.ILLink.Tasks": {
"type": "Direct",
"requested": "[10.0.6, )",
"resolved": "10.0.6",
"contentHash": "QKuvS0LWX4fjFqeDkyM7Kqt8P3wYTiPD4nwU+9y59n0sCiG714fxDgbbN82vDnzq89AF/PiHl92TP2C4aFDUQA=="
},
"Microsoft.NETFramework.ReferenceAssemblies": {
"type": "Direct",
"requested": "[1.0.3, )",
"resolved": "1.0.3",
"contentHash": "vUc9Npcs14QsyOD01tnv/m8sQUnGTGOw1BCmKcv77LBJY7OxhJ+zJF7UD/sCL3lYNFuqmQEVlkfS4Quif6FyYg==",
"dependencies": {
"Microsoft.NETFramework.ReferenceAssemblies.net461": "1.0.3"
}
},
"Microsoft.SourceLink.GitHub": {
"type": "Direct",
"requested": "[10.0.102, )",
"resolved": "10.0.102",
"contentHash": "Oxq3RCIJSdtpIU4hLqO7XaDe/Ra3HS9Wi8rJl838SAg6Zu1iQjerA0+xXWBgUFYbgknUGCLOU0T+lzMLkvY9Qg==",
"dependencies": {
"Microsoft.Build.Tasks.Git": "10.0.102",
"Microsoft.SourceLink.Common": "10.0.102"
}
},
"Microsoft.VisualStudio.Threading.Analyzers": {
"type": "Direct",
"requested": "[17.14.15, )",
"resolved": "17.14.15",
"contentHash": "mXQPJsbuUD2ydq4/ffd8h8tSOFCXec+2xJOVNCvXjuMOq/+5EKHq3D2m2MC2+nUaXeFMSt66VS/J4HdKBixgcw=="
},
"PolySharp": {
"type": "Direct",
"requested": "[1.15.0, )",
"resolved": "1.15.0",
"contentHash": "FbU0El+EEjdpuIX4iDbeS7ki1uzpJPx8vbqOzEtqnl1GZeAGJfq+jCbxeJL2y0EPnUNk8dRnnqR2xnYXg9Tf+g=="
},
"Microsoft.Build.Tasks.Git": {
"type": "Transitive",
"resolved": "10.0.102",
"contentHash": "0i81LYX31U6UiXz4NOLbvc++u+/mVDmOt+PskrM/MygpDxkv9THKQyRUmavBpLK6iBV0abNWnn+CQgSRz//Pwg=="
},
"Microsoft.NETFramework.ReferenceAssemblies.net461": {
"type": "Transitive",
"resolved": "1.0.3",
"contentHash": "AmOJZwCqnOCNp6PPcf9joyogScWLtwy0M1WkqfEQ0M9nYwyDD7EX9ZjscKS5iYnyvteX7kzSKFCKt9I9dXA6mA=="
},
"Microsoft.SourceLink.Common": {
"type": "Transitive",
"resolved": "10.0.102",
"contentHash": "Mk1IMb9q5tahC2NltxYXFkLBtuBvfBoCQ3pIxYQWfzbCE9o1OB9SsHe0hnNGo7lWgTA/ePbFAJLWu6nLL9K17A=="
},
"sharpcompress": {
"type": "Project"
}
},
"net10.0/osx-arm64": {
"Microsoft.DotNet.ILCompiler": {
"type": "Direct",
"requested": "[10.0.6, )",
"resolved": "10.0.6",
"contentHash": "nBOzxOys8OeyJ+Nsi/uYlI/5TSsvwjaM/p5m4dTL6khCLx9UuP3b2ec3HeuBw/+F7hHCAZG1yFx8VBeoRAX+EQ==",
"dependencies": {
"runtime.osx-arm64.Microsoft.DotNet.ILCompiler": "10.0.6"
}
},
"runtime.osx-arm64.Microsoft.DotNet.ILCompiler": {
"type": "Transitive",
"resolved": "10.0.6",
"contentHash": "+yovwOAlIpfIcH+ZWmLYXWTSWYJ93wcQxF/RVk+X4MXgLASeosCJYVLqP20g0cufKjoRqvCmnklR6y9Su3ORtA=="
}
Comment thread
adamhathcock marked this conversation as resolved.
}
}
}
17 changes: 10 additions & 7 deletions tests/SharpCompress.Performance/Benchmarks/TarBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using SharpCompress.Archives;
using SharpCompress.Archives.Tar;
using SharpCompress.Common;
using SharpCompress.Compressors;
Expand Down Expand Up @@ -67,11 +68,11 @@ public void TarExtractReaderApi()
[Benchmark(Description = "Tar: Extract all entries (Archive API) - SystemGzip")]
public void SystemTarExtractArchiveApi()
{
using var stream = new MemoryStream(_tarBytes);
using var archive = TarArchive.OpenArchive(
using var stream = new MemoryStream(_tarGzBytes);
using var archive = ArchiveFactory.OpenArchive(
stream,
ReaderOptions.ForExternalStream.WithProviders(
CompressionProviderRegistry.Empty.With(new SystemGZipCompressionProvider())
CompressionProviderRegistry.Default.With(new SystemGZipCompressionProvider())
)
);
foreach (var entry in archive.Entries.Where(e => !e.IsDirectory))
Expand All @@ -84,11 +85,11 @@ public void SystemTarExtractArchiveApi()
[Benchmark(Description = "Tar: Extract all entries (Reader API) - SystemGzip")]
public void SystemTarExtractReaderApi()
{
using var stream = new MemoryStream(_tarBytes);
using var stream = new MemoryStream(_tarGzBytes);
using var reader = ReaderFactory.OpenReader(
stream,
ReaderOptions.ForExternalStream.WithProviders(
CompressionProviderRegistry.Empty.With(new SystemGZipCompressionProvider())
CompressionProviderRegistry.Default.With(new SystemGZipCompressionProvider())
)
);
while (reader.MoveToNextEntry())
Expand All @@ -104,7 +105,7 @@ public void SystemTarExtractReaderApi()
public void TarGzipExtract()
{
using var stream = new MemoryStream(_tarGzBytes);
using var archive = TarArchive.OpenArchive(stream);
using var archive = ArchiveFactory.OpenArchive(stream);
foreach (var entry in archive.Entries.Where(e => !e.IsDirectory))
{
using var entryStream = entry.OpenEntryStream();
Expand All @@ -116,7 +117,9 @@ public void TarGzipExtract()
public async Task TarGzipExtractAsync()
{
using var stream = new MemoryStream(_tarGzBytes);
await using var archive = await TarArchive.OpenAsyncArchive(stream).ConfigureAwait(false);
await using var archive = await ArchiveFactory
.OpenAsyncArchive(stream)
.ConfigureAwait(false);
await foreach (var entry in archive.EntriesAsync.Where(e => !e.IsDirectory))
{
await using var entryStream = await entry.OpenEntryStreamAsync().ConfigureAwait(false);
Expand Down
Loading
Loading