diff --git a/src/SharpCompress/Archives/SevenZip/SevenZipArchive.Factory.cs b/src/SharpCompress/Archives/SevenZip/SevenZipArchive.Factory.cs index 30adbaf9..67f0a1ff 100644 --- a/src/SharpCompress/Archives/SevenZip/SevenZipArchive.Factory.cs +++ b/src/SharpCompress/Archives/SevenZip/SevenZipArchive.Factory.cs @@ -12,11 +12,11 @@ namespace SharpCompress.Archives.SevenZip; public partial class SevenZipArchive #if NET8_0_OR_GREATER - : IArchiveOpenable, - IMultiArchiveOpenable + : IArchiveOpenable, + IMultiArchiveOpenable #endif { - public static ValueTask OpenAsyncArchive( + public static ValueTask OpenAsyncArchive( string path, ReaderOptions? readerOptions = null, CancellationToken cancellationToken = default @@ -25,17 +25,23 @@ public partial class SevenZipArchive cancellationToken.ThrowIfCancellationRequested(); path.NotNullOrEmpty("path"); return new( - (IAsyncArchive)OpenArchive(new FileInfo(path), readerOptions ?? new ReaderOptions()) + (ISevenZipAsyncArchive)OpenArchive( + new FileInfo(path), + readerOptions ?? new ReaderOptions() + ) ); } - public static IArchive OpenArchive(string filePath, ReaderOptions? readerOptions = null) + public static ISevenZipArchive OpenArchive(string filePath, ReaderOptions? readerOptions = null) { filePath.NotNullOrEmpty("filePath"); return OpenArchive(new FileInfo(filePath), readerOptions ?? new ReaderOptions()); } - public static IArchive OpenArchive(FileInfo fileInfo, ReaderOptions? readerOptions = null) + public static ISevenZipArchive OpenArchive( + FileInfo fileInfo, + ReaderOptions? readerOptions = null + ) { fileInfo.NotNull(nameof(fileInfo)); return new SevenZipArchive( @@ -47,7 +53,7 @@ public partial class SevenZipArchive ); } - public static IArchive OpenArchive( + public static ISevenZipArchive OpenArchive( IEnumerable fileInfos, ReaderOptions? readerOptions = null ) @@ -63,7 +69,7 @@ public partial class SevenZipArchive ); } - public static IArchive OpenArchive( + public static ISevenZipArchive OpenArchive( IEnumerable streams, ReaderOptions? readerOptions = null ) @@ -79,7 +85,7 @@ public partial class SevenZipArchive ); } - public static IArchive OpenArchive(Stream stream, ReaderOptions? readerOptions = null) + public static ISevenZipArchive OpenArchive(Stream stream, ReaderOptions? readerOptions = null) { stream.NotNull(nameof(stream)); @@ -93,44 +99,44 @@ public partial class SevenZipArchive ); } - public static ValueTask OpenAsyncArchive( + public static ValueTask OpenAsyncArchive( Stream stream, ReaderOptions? readerOptions = null, CancellationToken cancellationToken = default ) { cancellationToken.ThrowIfCancellationRequested(); - return new((IAsyncArchive)OpenArchive(stream, readerOptions)); + return new((ISevenZipAsyncArchive)OpenArchive(stream, readerOptions)); } - public static ValueTask OpenAsyncArchive( + public static ValueTask OpenAsyncArchive( FileInfo fileInfo, ReaderOptions? readerOptions = null, CancellationToken cancellationToken = default ) { cancellationToken.ThrowIfCancellationRequested(); - return new((IAsyncArchive)OpenArchive(fileInfo, readerOptions)); + return new((ISevenZipAsyncArchive)OpenArchive(fileInfo, readerOptions)); } - public static ValueTask OpenAsyncArchive( + public static ValueTask OpenAsyncArchive( IReadOnlyList streams, ReaderOptions? readerOptions = null, CancellationToken cancellationToken = default ) { cancellationToken.ThrowIfCancellationRequested(); - return new((IAsyncArchive)OpenArchive(streams, readerOptions)); + return new((ISevenZipAsyncArchive)OpenArchive(streams, readerOptions)); } - public static ValueTask OpenAsyncArchive( + public static ValueTask OpenAsyncArchive( IReadOnlyList fileInfos, ReaderOptions? readerOptions = null, CancellationToken cancellationToken = default ) { cancellationToken.ThrowIfCancellationRequested(); - return new((IAsyncArchive)OpenArchive(fileInfos, readerOptions)); + return new((ISevenZipAsyncArchive)OpenArchive(fileInfos, readerOptions)); } public static bool IsSevenZipFile(string filePath) => IsSevenZipFile(new FileInfo(filePath)); diff --git a/src/SharpCompress/Factories/ZipFactory.cs b/src/SharpCompress/Factories/ZipFactory.cs index 6c683a38..d93d14b5 100644 --- a/src/SharpCompress/Factories/ZipFactory.cs +++ b/src/SharpCompress/Factories/ZipFactory.cs @@ -206,7 +206,7 @@ public class ZipFactory /// public IWriter OpenWriter(Stream stream, IWriterOptions writerOptions) { - ZipWriterOptions zipOptions = writerOptions switch + var zipOptions = writerOptions switch { ZipWriterOptions zwo => zwo, WriterOptions wo => new ZipWriterOptions(wo), diff --git a/src/SharpCompress/Readers/Zip/ZipReader.Factory.cs b/src/SharpCompress/Readers/Zip/ZipReader.Factory.cs index 4a2b18f8..66d8549b 100644 --- a/src/SharpCompress/Readers/Zip/ZipReader.Factory.cs +++ b/src/SharpCompress/Readers/Zip/ZipReader.Factory.cs @@ -1,4 +1,3 @@ - using System.Collections.Generic; using System.IO; using System.Threading; @@ -12,8 +11,6 @@ public partial class ZipReader : IReaderOpenable #endif { - - /// /// Opens a ZipReader for Non-seeking usage with a single volume /// diff --git a/src/SharpCompress/Readers/Zip/ZipReader.cs b/src/SharpCompress/Readers/Zip/ZipReader.cs index 22be2278..969e3b4f 100644 --- a/src/SharpCompress/Readers/Zip/ZipReader.cs +++ b/src/SharpCompress/Readers/Zip/ZipReader.cs @@ -37,7 +37,6 @@ public partial class ZipReader : AbstractReader, IZipReader public override ZipVolume Volume { get; } - protected override IEnumerable GetEntries(Stream stream) { foreach (var h in _headerFactory.ReadStreamHeader(stream)) diff --git a/tests/SharpCompress.Test/SevenZip/SevenZipArchiveTests.cs b/tests/SharpCompress.Test/SevenZip/SevenZipArchiveTests.cs index 09828fcf..534f3cfb 100644 --- a/tests/SharpCompress.Test/SevenZip/SevenZipArchiveTests.cs +++ b/tests/SharpCompress.Test/SevenZip/SevenZipArchiveTests.cs @@ -307,7 +307,7 @@ public class SevenZipArchiveTests : ArchiveTests using var reader = archive.ExtractAllEntries(); - Assert.IsType(reader); + Assert.IsAssignableFrom(reader); SevenZipReader sevenZipReader = (SevenZipReader)reader; sevenZipReader.DiagnosticsEnabled = true;