diff --git a/Directory.Build.props b/Directory.Build.props index c8a00413..bcbdc590 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -31,7 +31,8 @@ CA1710;CA1711;CA1720;CA1724; - CA1502;CA1716;NETSDK1206;IDE0017;IDE0040;IDE0044;IDE0051;IDE0052;IDE0060;IDE1006;IDE1007;IDE1033;IDE1036;IDE1040;IDE1041;IDE1045;IDE1050;IDE1051;IDE1055;IDE1060;IDE1063;IDE1070;IDE1071;IDE1075;IDE1080;IDE1090;CA1034;CA1051;CA1063; + CA1502;CA1716;NETSDK1206;IDE0017;IDE0032;IDE0040;IDE0044;IDE0051;IDE0052;IDE0060;IDE0251;IDE1006;IDE1007;IDE1033;IDE1036;IDE1040;IDE1041;IDE1045;IDE1050;IDE1051;IDE1055;IDE1060;IDE1063; + IDE1070;IDE1071;IDE1075;IDE1080;IDE1090;CA1027;CA1031;CA1032;CA1033;CA1028;CA1034;CA1051;CA1063;CA1069;CA1505;CA1802;CA1814;CA1819;CA1805;CA2225;CA2237; $(NoWarn) diff --git a/src/SharpCompress/Archives/GZip/GZipArchiveEntry.cs b/src/SharpCompress/Archives/GZip/GZipArchiveEntry.cs index f00e889c..1f85453b 100644 --- a/src/SharpCompress/Archives/GZip/GZipArchiveEntry.cs +++ b/src/SharpCompress/Archives/GZip/GZipArchiveEntry.cs @@ -7,7 +7,10 @@ namespace SharpCompress.Archives.GZip; public class GZipArchiveEntry : GZipEntry, IArchiveEntry { internal GZipArchiveEntry(GZipArchive archive, GZipFilePart? part) - : base(part) => Archive = archive; + : base(part) + { + Archive = archive; + } public virtual Stream OpenEntryStream() { diff --git a/src/SharpCompress/Archives/Rar/FileInfoRarFilePart.cs b/src/SharpCompress/Archives/Rar/FileInfoRarFilePart.cs index 02d2f769..41886ef1 100644 --- a/src/SharpCompress/Archives/Rar/FileInfoRarFilePart.cs +++ b/src/SharpCompress/Archives/Rar/FileInfoRarFilePart.cs @@ -12,7 +12,10 @@ internal sealed class FileInfoRarFilePart : SeekableFilePart FileHeader fh, FileInfo fi ) - : base(mh, fh, volume.Index, volume.Stream, password) => FileInfo = fi; + : base(mh, fh, volume.Index, volume.Stream, password) + { + FileInfo = fi; + } internal FileInfo FileInfo { get; } diff --git a/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs b/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs index cfbb8093..5ef3137d 100644 --- a/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs +++ b/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs @@ -216,7 +216,10 @@ public class SevenZipArchive : AbstractArchive _archive = archive; + : base(readerOptions, ArchiveType.SevenZip) + { + _archive = archive; + } public override SevenZipVolume Volume => _archive.Volumes.Single(); @@ -266,7 +269,10 @@ public class SevenZipArchive : AbstractArchive _password = password; + public PasswordProvider(string? password) + { + _password = password; + } public string? CryptoGetTextPassword() => _password; } diff --git a/src/SharpCompress/Archives/SevenZip/SevenZipArchiveEntry.cs b/src/SharpCompress/Archives/SevenZip/SevenZipArchiveEntry.cs index 9824ca47..ef398c84 100644 --- a/src/SharpCompress/Archives/SevenZip/SevenZipArchiveEntry.cs +++ b/src/SharpCompress/Archives/SevenZip/SevenZipArchiveEntry.cs @@ -6,7 +6,10 @@ namespace SharpCompress.Archives.SevenZip; public class SevenZipArchiveEntry : SevenZipEntry, IArchiveEntry { internal SevenZipArchiveEntry(SevenZipArchive archive, SevenZipFilePart part) - : base(part) => Archive = archive; + : base(part) + { + Archive = archive; + } public Stream OpenEntryStream() => FilePart.GetCompressedStream(); diff --git a/src/SharpCompress/Archives/Tar/TarArchiveEntry.cs b/src/SharpCompress/Archives/Tar/TarArchiveEntry.cs index 770a7109..539949d1 100644 --- a/src/SharpCompress/Archives/Tar/TarArchiveEntry.cs +++ b/src/SharpCompress/Archives/Tar/TarArchiveEntry.cs @@ -8,7 +8,10 @@ namespace SharpCompress.Archives.Tar; public class TarArchiveEntry : TarEntry, IArchiveEntry { internal TarArchiveEntry(TarArchive archive, TarFilePart? part, CompressionType compressionType) - : base(part, compressionType) => Archive = archive; + : base(part, compressionType) + { + Archive = archive; + } public virtual Stream OpenEntryStream() => Parts.Single().GetCompressedStream().NotNull(); diff --git a/src/SharpCompress/Archives/Zip/ZipArchive.cs b/src/SharpCompress/Archives/Zip/ZipArchive.cs index 9445df9a..9b55823a 100644 --- a/src/SharpCompress/Archives/Zip/ZipArchive.cs +++ b/src/SharpCompress/Archives/Zip/ZipArchive.cs @@ -29,11 +29,13 @@ public class ZipArchive : AbstractWritableArchive /// /// internal ZipArchive(SourceStream sourceStream) - : base(ArchiveType.Zip, sourceStream) => - headerFactory = new SeekableZipHeaderFactory( - sourceStream.ReaderOptions.Password, - sourceStream.ReaderOptions.ArchiveEncoding - ); + : base(ArchiveType.Zip, sourceStream) + { + headerFactory = new SeekableZipHeaderFactory( + sourceStream.ReaderOptions.Password, + sourceStream.ReaderOptions.ArchiveEncoding + ); + } /// /// Constructor expects a filepath to an existing file. diff --git a/src/SharpCompress/Archives/Zip/ZipArchiveEntry.cs b/src/SharpCompress/Archives/Zip/ZipArchiveEntry.cs index 4c980f91..8c0853c8 100644 --- a/src/SharpCompress/Archives/Zip/ZipArchiveEntry.cs +++ b/src/SharpCompress/Archives/Zip/ZipArchiveEntry.cs @@ -7,7 +7,10 @@ namespace SharpCompress.Archives.Zip; public class ZipArchiveEntry : ZipEntry, IArchiveEntry { internal ZipArchiveEntry(ZipArchive archive, SeekableZipFilePart? part) - : base(part) => Archive = archive; + : base(part) + { + Archive = archive; + } public virtual Stream OpenEntryStream() => Parts.Single().GetCompressedStream().NotNull(); diff --git a/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs b/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs index 0f0b6517..b484ea70 100644 --- a/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs +++ b/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs @@ -8,7 +8,7 @@ internal static class ZipArchiveVolumeFactory { internal static FileInfo? GetFilePart(int index, FileInfo part1) //base the name on the first part { - FileInfo? item = null; + FileInfo item; //load files with zip/zipx first. Swapped to end once loaded in ZipArchive //new style .zip, z01.. | .zipx, zx01 - if the numbers go beyond 99 then they use 100 ...1000 etc @@ -31,7 +31,7 @@ internal static class ZipArchiveVolumeFactory return ArchiveVolumeFactory.GetFilePart(index, part1); } - if (item != null && item.Exists) + if (item.Exists) { return item; } diff --git a/src/SharpCompress/Common/Arc/ArcEntryHeader.cs b/src/SharpCompress/Common/Arc/ArcEntryHeader.cs index 821f64e0..fc3a15f4 100644 --- a/src/SharpCompress/Common/Arc/ArcEntryHeader.cs +++ b/src/SharpCompress/Common/Arc/ArcEntryHeader.cs @@ -51,24 +51,21 @@ public class ArcEntryHeader return this; } - private CompressionType GetCompressionType(byte value) - { - return value switch - { - 1 or 2 => CompressionType.None, - 3 => CompressionType.RLE90, - 4 => CompressionType.Squeezed, - 5 or 6 or 7 or 8 => CompressionType.Crunched, - 9 => CompressionType.Squashed, - 10 => CompressionType.Crushed, - 11 => CompressionType.Distilled, - _ => CompressionType.Unknown, - }; - } + private CompressionType GetCompressionType(byte value) => + value switch + { + 1 or 2 => CompressionType.None, + 3 => CompressionType.RLE90, + 4 => CompressionType.Squeezed, + 5 or 6 or 7 or 8 => CompressionType.Crunched, + 9 => CompressionType.Squashed, + 10 => CompressionType.Crushed, + 11 => CompressionType.Distilled, + _ => CompressionType.Unknown, + }; - public static DateTime ConvertToDateTime(long rawDateTime) - { - // Convert Unix timestamp to DateTime (UTC) - return DateTimeOffset.FromUnixTimeSeconds(rawDateTime).UtcDateTime; - } + public static DateTime ConvertToDateTime(long rawDateTime) => + + // Convert Unix timestamp to DateTime (UTC) + DateTimeOffset.FromUnixTimeSeconds(rawDateTime).UtcDateTime; } diff --git a/src/SharpCompress/Common/ArchiveEncoding.cs b/src/SharpCompress/Common/ArchiveEncoding.cs index 3701a93b..07da3255 100644 --- a/src/SharpCompress/Common/ArchiveEncoding.cs +++ b/src/SharpCompress/Common/ArchiveEncoding.cs @@ -36,7 +36,10 @@ public class ArchiveEncoding } #if !NETFRAMEWORK - static ArchiveEncoding() => Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + static ArchiveEncoding() + { + Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); + } #endif public string Decode(byte[] bytes) => Decode(bytes, 0, bytes.Length); diff --git a/src/SharpCompress/Common/ArchiveExtractionEventArgs.cs b/src/SharpCompress/Common/ArchiveExtractionEventArgs.cs index 80817748..5b13ee19 100644 --- a/src/SharpCompress/Common/ArchiveExtractionEventArgs.cs +++ b/src/SharpCompress/Common/ArchiveExtractionEventArgs.cs @@ -4,7 +4,10 @@ namespace SharpCompress.Common; public class ArchiveExtractionEventArgs : EventArgs { - internal ArchiveExtractionEventArgs(T entry) => Item = entry; + internal ArchiveExtractionEventArgs(T entry) + { + Item = entry; + } public T Item { get; } } diff --git a/src/SharpCompress/Common/EntryStream.cs b/src/SharpCompress/Common/EntryStream.cs index a0fe736a..d1d8097f 100644 --- a/src/SharpCompress/Common/EntryStream.cs +++ b/src/SharpCompress/Common/EntryStream.cs @@ -1,6 +1,5 @@ using System; using System.IO; -using System.IO.Compression; using SharpCompress.IO; using SharpCompress.Readers; diff --git a/src/SharpCompress/Common/FilePart.cs b/src/SharpCompress/Common/FilePart.cs index 54e3c9f9..d85ce351 100644 --- a/src/SharpCompress/Common/FilePart.cs +++ b/src/SharpCompress/Common/FilePart.cs @@ -4,7 +4,10 @@ namespace SharpCompress.Common; public abstract class FilePart { - protected FilePart(ArchiveEncoding archiveEncoding) => ArchiveEncoding = archiveEncoding; + protected FilePart(ArchiveEncoding archiveEncoding) + { + ArchiveEncoding = archiveEncoding; + } internal ArchiveEncoding ArchiveEncoding { get; } diff --git a/src/SharpCompress/Common/GZip/GZipEntry.cs b/src/SharpCompress/Common/GZip/GZipEntry.cs index 9a551d07..11f2067b 100644 --- a/src/SharpCompress/Common/GZip/GZipEntry.cs +++ b/src/SharpCompress/Common/GZip/GZipEntry.cs @@ -8,7 +8,10 @@ public class GZipEntry : Entry { private readonly GZipFilePart? _filePart; - internal GZipEntry(GZipFilePart? filePart) => _filePart = filePart; + internal GZipEntry(GZipFilePart? filePart) + { + _filePart = filePart; + } public override CompressionType CompressionType => CompressionType.GZip; diff --git a/src/SharpCompress/Common/GZip/GZipVolume.cs b/src/SharpCompress/Common/GZip/GZipVolume.cs index 600ba8e3..51fb1283 100644 --- a/src/SharpCompress/Common/GZip/GZipVolume.cs +++ b/src/SharpCompress/Common/GZip/GZipVolume.cs @@ -9,7 +9,10 @@ public class GZipVolume : Volume : base(stream, options, index) { } public GZipVolume(FileInfo fileInfo, ReaderOptions options) - : base(fileInfo.OpenRead(), options) => options.LeaveStreamOpen = false; + : base(fileInfo.OpenRead(), options) + { + options.LeaveStreamOpen = false; + } public override bool IsFirstVolume => true; diff --git a/src/SharpCompress/Common/Rar/CryptKey3.cs b/src/SharpCompress/Common/Rar/CryptKey3.cs index 93e451b1..df1a5890 100644 --- a/src/SharpCompress/Common/Rar/CryptKey3.cs +++ b/src/SharpCompress/Common/Rar/CryptKey3.cs @@ -12,7 +12,10 @@ internal class CryptKey3 : ICryptKey private string _password; - public CryptKey3(string password) => _password = password ?? ""; + public CryptKey3(string password) + { + _password = password ?? ""; + } public ICryptoTransform Transformer(byte[] salt) { diff --git a/src/SharpCompress/Common/Rar/Headers/MarkHeader.cs b/src/SharpCompress/Common/Rar/Headers/MarkHeader.cs index 9ca0f9b2..df766210 100644 --- a/src/SharpCompress/Common/Rar/Headers/MarkHeader.cs +++ b/src/SharpCompress/Common/Rar/Headers/MarkHeader.cs @@ -11,7 +11,10 @@ internal class MarkHeader : IRarHeader public bool IsRar5 { get; } - private MarkHeader(bool isRar5) => IsRar5 = isRar5; + private MarkHeader(bool isRar5) + { + IsRar5 = isRar5; + } public HeaderType HeaderType => HeaderType.Mark; diff --git a/src/SharpCompress/Common/Rar/Headers/NewSubHeaderType.cs b/src/SharpCompress/Common/Rar/Headers/NewSubHeaderType.cs index b45f98bb..6c11bb51 100644 --- a/src/SharpCompress/Common/Rar/Headers/NewSubHeaderType.cs +++ b/src/SharpCompress/Common/Rar/Headers/NewSubHeaderType.cs @@ -42,4 +42,8 @@ internal sealed class NewSubHeaderType : IEquatable } public bool Equals(NewSubHeaderType? other) => other is not null && Equals(other._bytes); + + public override bool Equals(object? obj) => obj is NewSubHeaderType other && Equals(other); + + public override int GetHashCode() => _bytes.GetHashCode(); } diff --git a/src/SharpCompress/Common/Rar/RarCryptoBinaryReader.cs b/src/SharpCompress/Common/Rar/RarCryptoBinaryReader.cs index 6e44286b..26878cd2 100644 --- a/src/SharpCompress/Common/Rar/RarCryptoBinaryReader.cs +++ b/src/SharpCompress/Common/Rar/RarCryptoBinaryReader.cs @@ -22,7 +22,10 @@ internal sealed class RarCryptoBinaryReader : RarCrcBinaryReader } public RarCryptoBinaryReader(Stream stream, ICryptKey cryptKey, byte[] salt) - : base(stream) => _rijndael = new BlockTransformer(cryptKey.Transformer(salt)); + : base(stream) + { + _rijndael = new BlockTransformer(cryptKey.Transformer(salt)); + } // track read count ourselves rather than using the underlying stream since we buffer public override long CurrentReadByteCount diff --git a/src/SharpCompress/Common/Rar/RarVolume.cs b/src/SharpCompress/Common/Rar/RarVolume.cs index 4bb2f84a..52dcf157 100644 --- a/src/SharpCompress/Common/Rar/RarVolume.cs +++ b/src/SharpCompress/Common/Rar/RarVolume.cs @@ -18,7 +18,10 @@ public abstract class RarVolume : Volume private int _maxCompressionAlgorithm; internal RarVolume(StreamingMode mode, Stream stream, ReaderOptions options, int index) - : base(stream, options, index) => _headerFactory = new RarHeaderFactory(mode, options); + : base(stream, options, index) + { + _headerFactory = new RarHeaderFactory(mode, options); + } private ArchiveHeader? ArchiveHeader { get; set; } diff --git a/src/SharpCompress/Common/SevenZip/ArchiveDatabase.cs b/src/SharpCompress/Common/SevenZip/ArchiveDatabase.cs index 8b6a541f..f05cef55 100644 --- a/src/SharpCompress/Common/SevenZip/ArchiveDatabase.cs +++ b/src/SharpCompress/Common/SevenZip/ArchiveDatabase.cs @@ -27,8 +27,10 @@ internal class ArchiveDatabase internal IPasswordProvider PasswordProvider { get; } - public ArchiveDatabase(IPasswordProvider passwordProvider) => - PasswordProvider = passwordProvider; + public ArchiveDatabase(IPasswordProvider passwordProvider) + { + PasswordProvider = passwordProvider; + } internal void Clear() { diff --git a/src/SharpCompress/Common/SevenZip/CFileItem.cs b/src/SharpCompress/Common/SevenZip/CFileItem.cs index 254a444f..050f8bde 100644 --- a/src/SharpCompress/Common/SevenZip/CFileItem.cs +++ b/src/SharpCompress/Common/SevenZip/CFileItem.cs @@ -22,5 +22,8 @@ internal class CFileItem public long? StartPos { get; internal set; } public bool IsAnti { get; internal set; } - internal CFileItem() => HasStream = true; + internal CFileItem() + { + HasStream = true; + } } diff --git a/src/SharpCompress/Common/SevenZip/CMethodId.cs b/src/SharpCompress/Common/SevenZip/CMethodId.cs index 8494aad5..143e4943 100644 --- a/src/SharpCompress/Common/SevenZip/CMethodId.cs +++ b/src/SharpCompress/Common/SevenZip/CMethodId.cs @@ -1,6 +1,9 @@ -namespace SharpCompress.Common.SevenZip; +using System; -internal readonly struct CMethodId +namespace SharpCompress.Common.SevenZip; + + +internal readonly struct CMethodId : IEquatable { public const ulong K_COPY_ID = 0; public const ulong K_LZMA_ID = 0x030101; @@ -14,7 +17,10 @@ internal readonly struct CMethodId public readonly ulong _id; - public CMethodId(ulong id) => _id = id; + public CMethodId(ulong id) + { + _id = id; + } public override int GetHashCode() => _id.GetHashCode(); diff --git a/src/SharpCompress/Common/SevenZip/SevenZipEntry.cs b/src/SharpCompress/Common/SevenZip/SevenZipEntry.cs index 79df43a0..8fa7f519 100644 --- a/src/SharpCompress/Common/SevenZip/SevenZipEntry.cs +++ b/src/SharpCompress/Common/SevenZip/SevenZipEntry.cs @@ -5,7 +5,10 @@ namespace SharpCompress.Common.SevenZip; public class SevenZipEntry : Entry { - internal SevenZipEntry(SevenZipFilePart filePart) => FilePart = filePart; + internal SevenZipEntry(SevenZipFilePart filePart) + { + FilePart = filePart; + } internal SevenZipFilePart FilePart { get; } diff --git a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs index 4992b0fc..b485e5ed 100644 --- a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs +++ b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs @@ -9,7 +9,10 @@ internal sealed class TarHeader { internal static readonly DateTime EPOCH = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); - public TarHeader(ArchiveEncoding archiveEncoding) => ArchiveEncoding = archiveEncoding; + public TarHeader(ArchiveEncoding archiveEncoding) + { + ArchiveEncoding = archiveEncoding; + } internal string? Name { get; set; } internal string? LinkName { get; set; } diff --git a/src/SharpCompress/Common/Zip/SeekableZipFilePart.cs b/src/SharpCompress/Common/Zip/SeekableZipFilePart.cs index e7572711..904dd534 100644 --- a/src/SharpCompress/Common/Zip/SeekableZipFilePart.cs +++ b/src/SharpCompress/Common/Zip/SeekableZipFilePart.cs @@ -13,7 +13,10 @@ internal class SeekableZipFilePart : ZipFilePart DirectoryEntryHeader header, Stream stream ) - : base(header, stream) => _headerFactory = headerFactory; + : base(header, stream) + { + _headerFactory = headerFactory; + } internal override Stream GetCompressedStream() { diff --git a/src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs b/src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs index 89d38273..fd489dc2 100644 --- a/src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs +++ b/src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs @@ -16,7 +16,10 @@ internal class StreamingZipHeaderFactory : ZipHeaderFactory ArchiveEncoding archiveEncoding, IEnumerable? entries ) - : base(StreamingMode.Streaming, password, archiveEncoding) => _entries = entries; + : base(StreamingMode.Streaming, password, archiveEncoding) + { + _entries = entries; + } internal IEnumerable ReadStreamHeader(Stream stream) { diff --git a/src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs b/src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs index abff4973..2042a502 100644 --- a/src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs +++ b/src/SharpCompress/Compressors/BZip2/CBZip2InputStream.cs @@ -60,20 +60,16 @@ internal class CBZip2InputStream : Stream, IStreamStack void IStreamStack.SetPosition(long position) { } - private static void Cadvise() - { - //System.out.Println("CRC Error"); - throw new InvalidOperationException("BZip2 error"); - } + private static void Cadvise() => throw + + //System.out.Println("CRC Error"); + new InvalidOperationException("BZip2 error"); private static void BadBGLengths() => Cadvise(); private static void BitStreamEOF() => Cadvise(); - private static void CompressedStreamEOF() - { - throw new InvalidOperationException("BZip2 compressed file ends unexpectedly"); - } + private static void CompressedStreamEOF() => throw new InvalidOperationException("BZip2 compressed file ends unexpectedly"); private void MakeMaps() { diff --git a/src/SharpCompress/Compressors/BZip2/CRC.cs b/src/SharpCompress/Compressors/BZip2/CRC.cs index 16be56e2..b2f3f5e8 100644 --- a/src/SharpCompress/Compressors/BZip2/CRC.cs +++ b/src/SharpCompress/Compressors/BZip2/CRC.cs @@ -291,7 +291,10 @@ internal class CRC unchecked((int)0xb1f740b4) ]; - public CRC() => InitialiseCRC(); + public CRC() + { + InitialiseCRC(); + } internal void InitialiseCRC() => globalCrc = unchecked((int)0xffffffff); diff --git a/src/SharpCompress/Compressors/Deflate/DeflateManager.cs b/src/SharpCompress/Compressors/Deflate/DeflateManager.cs index 8dc91dbb..c5b74050 100644 --- a/src/SharpCompress/Compressors/Deflate/DeflateManager.cs +++ b/src/SharpCompress/Compressors/Deflate/DeflateManager.cs @@ -202,20 +202,22 @@ internal sealed partial class DeflateManager public static Config Lookup(CompressionLevel level) => Table[(int)level]; - static Config() => - Table = - [ - new Config(0, 0, 0, 0, DeflateFlavor.Store), - new Config(4, 4, 8, 4, DeflateFlavor.Fast), - new Config(4, 5, 16, 8, DeflateFlavor.Fast), - new Config(4, 6, 32, 32, DeflateFlavor.Fast), - new Config(4, 4, 16, 16, DeflateFlavor.Slow), - new Config(8, 16, 32, 32, DeflateFlavor.Slow), - new Config(8, 16, 128, 128, DeflateFlavor.Slow), - new Config(8, 32, 128, 256, DeflateFlavor.Slow), - new Config(32, 128, 258, 1024, DeflateFlavor.Slow), - new Config(32, 258, 258, 4096, DeflateFlavor.Slow) - ]; + static Config() + { + Table = + [ + new Config(0, 0, 0, 0, DeflateFlavor.Store), + new Config(4, 4, 8, 4, DeflateFlavor.Fast), + new Config(4, 5, 16, 8, DeflateFlavor.Fast), + new Config(4, 6, 32, 32, DeflateFlavor.Fast), + new Config(4, 4, 16, 16, DeflateFlavor.Slow), + new Config(8, 16, 32, 32, DeflateFlavor.Slow), + new Config(8, 16, 128, 128, DeflateFlavor.Slow), + new Config(8, 32, 128, 256, DeflateFlavor.Slow), + new Config(32, 128, 258, 1024, DeflateFlavor.Slow), + new Config(32, 258, 258, 4096, DeflateFlavor.Slow) + ]; + } private static readonly Config[] Table; } diff --git a/src/SharpCompress/Compressors/Deflate/DeflateStream.cs b/src/SharpCompress/Compressors/Deflate/DeflateStream.cs index 8f268f00..d8a4b711 100644 --- a/src/SharpCompress/Compressors/Deflate/DeflateStream.cs +++ b/src/SharpCompress/Compressors/Deflate/DeflateStream.cs @@ -27,7 +27,6 @@ using System; using System.IO; using System.Text; -using System.Threading; using SharpCompress.IO; namespace SharpCompress.Compressors.Deflate; diff --git a/src/SharpCompress/Compressors/Deflate/Inflate.cs b/src/SharpCompress/Compressors/Deflate/Inflate.cs index db831ea2..0accd1c4 100644 --- a/src/SharpCompress/Compressors/Deflate/Inflate.cs +++ b/src/SharpCompress/Compressors/Deflate/Inflate.cs @@ -1651,8 +1651,10 @@ internal sealed class InflateManager public InflateManager() { } - public InflateManager(bool expectRfc1950HeaderBytes) => - HandleRfc1950HeaderBytes = expectRfc1950HeaderBytes; + public InflateManager(bool expectRfc1950HeaderBytes) + { + HandleRfc1950HeaderBytes = expectRfc1950HeaderBytes; + } internal bool HandleRfc1950HeaderBytes { get; set; } = true; diff --git a/src/SharpCompress/Compressors/Deflate64/DeflateInput.cs b/src/SharpCompress/Compressors/Deflate64/DeflateInput.cs index 304a2a78..7c7917bb 100644 --- a/src/SharpCompress/Compressors/Deflate64/DeflateInput.cs +++ b/src/SharpCompress/Compressors/Deflate64/DeflateInput.cs @@ -8,7 +8,10 @@ namespace SharpCompress.Compressors.Deflate64; internal sealed class DeflateInput { - public DeflateInput(byte[] buffer) => Buffer = buffer; + public DeflateInput(byte[] buffer) + { + Buffer = buffer; + } public byte[] Buffer { get; } public int Count { get; set; } diff --git a/src/SharpCompress/Compressors/Explode/ExplodeStream.cs b/src/SharpCompress/Compressors/Explode/ExplodeStream.cs index 156a6de2..0215c45d 100644 --- a/src/SharpCompress/Compressors/Explode/ExplodeStream.cs +++ b/src/SharpCompress/Compressors/Explode/ExplodeStream.cs @@ -86,25 +86,13 @@ public class ExplodeStream : Stream, IStreamStack base.Dispose(disposing); } - public override void Flush() - { - throw new NotImplementedException(); - } + public override void Flush() => throw new NotImplementedException(); - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotImplementedException(); - } + public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException(); - public override void SetLength(long value) - { - throw new NotImplementedException(); - } + public override void SetLength(long value) => throw new NotImplementedException(); - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotImplementedException(); - } + public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException(); public override bool CanRead => true; public override bool CanSeek => false; diff --git a/src/SharpCompress/Compressors/Filters/BCJFilter.cs b/src/SharpCompress/Compressors/Filters/BCJFilter.cs index cfda83f5..5a369fda 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilter.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilter.cs @@ -22,7 +22,10 @@ internal class BCJFilter : Filter private int _prevMask; public BCJFilter(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 5) => _pos = 5; + : base(isEncoder, baseStream, 5) + { + _pos = 5; + } private static bool Test86MsByte(byte b) => b == 0x00 || b == 0xFF; diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterARM.cs b/src/SharpCompress/Compressors/Filters/BCJFilterARM.cs index 5d861621..2ba79805 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterARM.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterARM.cs @@ -7,7 +7,10 @@ internal class BCJFilterARM : Filter private int _pos; public BCJFilterARM(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 8) => _pos = 8; + : base(isEncoder, baseStream, 8) + { + _pos = 8; + } protected override int Transform(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterARM64.cs b/src/SharpCompress/Compressors/Filters/BCJFilterARM64.cs index c701a5b5..254d8d40 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterARM64.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterARM64.cs @@ -9,7 +9,10 @@ internal class BCJFilterARM64 : Filter private int _pos; public BCJFilterARM64(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 8) => _pos = 0; + : base(isEncoder, baseStream, 8) + { + _pos = 0; + } protected override int Transform(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterARMT.cs b/src/SharpCompress/Compressors/Filters/BCJFilterARMT.cs index 89954f56..6e9615c9 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterARMT.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterARMT.cs @@ -7,7 +7,10 @@ internal class BCJFilterARMT : Filter private int _pos; public BCJFilterARMT(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 4) => _pos = 4; + : base(isEncoder, baseStream, 4) + { + _pos = 4; + } protected override int Transform(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterIA64.cs b/src/SharpCompress/Compressors/Filters/BCJFilterIA64.cs index 51225a23..f9b5befd 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterIA64.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterIA64.cs @@ -43,7 +43,10 @@ internal class BCJFilterIA64 : Filter ]; public BCJFilterIA64(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 16) => _pos = 0; + : base(isEncoder, baseStream, 16) + { + _pos = 0; + } protected override int Transform(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterPPC.cs b/src/SharpCompress/Compressors/Filters/BCJFilterPPC.cs index ccfa7480..3915017e 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterPPC.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterPPC.cs @@ -7,7 +7,10 @@ internal class BCJFilterPPC : Filter private int _pos; public BCJFilterPPC(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 4) => _pos = 0; + : base(isEncoder, baseStream, 4) + { + _pos = 0; + } protected override int Transform(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterRISCV.cs b/src/SharpCompress/Compressors/Filters/BCJFilterRISCV.cs index 32ad6ea2..345741e8 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterRISCV.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterRISCV.cs @@ -9,7 +9,10 @@ internal class BCJFilterRISCV : Filter private int _pos; public BCJFilterRISCV(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 8) => _pos = 0; + : base(isEncoder, baseStream, 8) + { + _pos = 0; + } private int Decode(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BCJFilterSPARC.cs b/src/SharpCompress/Compressors/Filters/BCJFilterSPARC.cs index db7c75be..3ccdeabe 100644 --- a/src/SharpCompress/Compressors/Filters/BCJFilterSPARC.cs +++ b/src/SharpCompress/Compressors/Filters/BCJFilterSPARC.cs @@ -7,7 +7,10 @@ internal class BCJFilterSPARC : Filter private int _pos; public BCJFilterSPARC(bool isEncoder, Stream baseStream) - : base(isEncoder, baseStream, 4) => _pos = 0; + : base(isEncoder, baseStream, 4) + { + _pos = 0; + } protected override int Transform(byte[] buffer, int offset, int count) { diff --git a/src/SharpCompress/Compressors/Filters/BranchExecFilter.cs b/src/SharpCompress/Compressors/Filters/BranchExecFilter.cs index bbe91196..64b93ce6 100644 --- a/src/SharpCompress/Compressors/Filters/BranchExecFilter.cs +++ b/src/SharpCompress/Compressors/Filters/BranchExecFilter.cs @@ -13,8 +13,9 @@ namespace SharpCompress.Compressors.Filters; [CLSCompliant(false)] public sealed class BranchExecFilter { - public enum Alignment : int + public enum Alignment { + None = 0, ARCH_x86_ALIGNMENT = 1, ARCH_PowerPC_ALIGNMENT = 4, ARCH_IA64_ALIGNMENT = 16, diff --git a/src/SharpCompress/Compressors/LZMA/Bcj2DecoderStream.cs b/src/SharpCompress/Compressors/LZMA/Bcj2DecoderStream.cs index de2d284f..60a5b5fa 100644 --- a/src/SharpCompress/Compressors/LZMA/Bcj2DecoderStream.cs +++ b/src/SharpCompress/Compressors/LZMA/Bcj2DecoderStream.cs @@ -69,7 +69,10 @@ internal class Bcj2DecoderStream : DecoderStream2, IStreamStack private uint _prob; - public StatusDecoder() => _prob = K_BIT_MODEL_TOTAL / 2; + public StatusDecoder() + { + _prob = K_BIT_MODEL_TOTAL / 2; + } public uint Decode(RangeDecoder decoder) { diff --git a/src/SharpCompress/Compressors/LZMA/ICoder.cs b/src/SharpCompress/Compressors/LZMA/ICoder.cs index 95134979..59ec105f 100644 --- a/src/SharpCompress/Compressors/LZMA/ICoder.cs +++ b/src/SharpCompress/Compressors/LZMA/ICoder.cs @@ -6,7 +6,7 @@ namespace SharpCompress.Compressors.LZMA; /// /// The exception that is thrown when an error in input stream occurs during decoding. /// -internal class DataErrorException : Exception +public class DataErrorException : Exception { public DataErrorException() : base("Data Error") { } @@ -15,7 +15,7 @@ internal class DataErrorException : Exception /// /// The exception that is thrown when the value of an argument is outside the allowable range. /// -internal class InvalidParamException : Exception +public class InvalidParamException : Exception { public InvalidParamException() : base("Invalid Parameter") { } diff --git a/src/SharpCompress/Compressors/LZMA/Log.cs b/src/SharpCompress/Compressors/LZMA/Log.cs index c2b5651e..c0e0b9c0 100644 --- a/src/SharpCompress/Compressors/LZMA/Log.cs +++ b/src/SharpCompress/Compressors/LZMA/Log.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; namespace SharpCompress.Compressors.LZMA; @@ -9,7 +8,10 @@ internal static class Log private static readonly Stack INDENT = new(); private static bool NEEDS_INDENT = true; - static Log() => INDENT.Push(""); + static Log() + { + INDENT.Push(""); + } public static void PushIndent(string indent = " ") => INDENT.Push(INDENT.Peek() + indent); diff --git a/src/SharpCompress/Compressors/Lzw/LzwStream.cs b/src/SharpCompress/Compressors/Lzw/LzwStream.cs index 9f0367fe..077ccefc 100644 --- a/src/SharpCompress/Compressors/Lzw/LzwStream.cs +++ b/src/SharpCompress/Compressors/Lzw/LzwStream.cs @@ -471,34 +471,22 @@ public class LzwStream : Stream, IStreamStack /// /// Gets a value indicating whether the current stream supports reading /// - public override bool CanRead - { - get { return baseInputStream.CanRead; } - } + public override bool CanRead => baseInputStream.CanRead; /// /// Gets a value of false indicating seeking is not supported for this stream. /// - public override bool CanSeek - { - get { return false; } - } + public override bool CanSeek => false; /// /// Gets a value of false indicating that this stream is not writeable. /// - public override bool CanWrite - { - get { return false; } - } + public override bool CanWrite => false; /// /// A value representing the length of the stream in bytes. /// - public override long Length - { - get { return got; } - } + public override long Length => got; /// /// The current position within the stream. @@ -507,17 +495,14 @@ public class LzwStream : Stream, IStreamStack /// Attempting to set the position public override long Position { - get { return baseInputStream.Position; } - set { throw new NotSupportedException("InflaterInputStream Position not supported"); } + get => baseInputStream.Position; + set => throw new NotSupportedException("InflaterInputStream Position not supported"); } /// /// Flushes the baseInputStream /// - public override void Flush() - { - baseInputStream.Flush(); - } + public override void Flush() => baseInputStream.Flush(); /// /// Sets the position within the current stream @@ -527,10 +512,7 @@ public class LzwStream : Stream, IStreamStack /// The defining where to seek from. /// The new position in the stream. /// Any access - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException("Seek not supported"); - } + public override long Seek(long offset, SeekOrigin origin) => throw new NotSupportedException("Seek not supported"); /// /// Set the length of the current stream @@ -538,10 +520,7 @@ public class LzwStream : Stream, IStreamStack /// /// The new length value for the stream. /// Any access - public override void SetLength(long value) - { - throw new NotSupportedException("InflaterInputStream SetLength not supported"); - } + public override void SetLength(long value) => throw new NotSupportedException("InflaterInputStream SetLength not supported"); /// /// Writes a sequence of bytes to stream and advances the current position @@ -551,10 +530,7 @@ public class LzwStream : Stream, IStreamStack /// The offset of the first byte to write. /// The number of bytes to write. /// Any access - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotSupportedException("InflaterInputStream Write not supported"); - } + public override void Write(byte[] buffer, int offset, int count) => throw new NotSupportedException("InflaterInputStream Write not supported"); /// /// Writes one byte to the current stream and advances the current position @@ -562,10 +538,7 @@ public class LzwStream : Stream, IStreamStack /// /// The byte to write. /// Any access - public override void WriteByte(byte value) - { - throw new NotSupportedException("InflaterInputStream WriteByte not supported"); - } + public override void WriteByte(byte value) => throw new NotSupportedException("InflaterInputStream WriteByte not supported"); /// /// Closes the input stream. When diff --git a/src/SharpCompress/Compressors/PPMd/H/PPMContext.cs b/src/SharpCompress/Compressors/PPMd/H/PPMContext.cs index 5b94545d..0b56db9c 100644 --- a/src/SharpCompress/Compressors/PPMd/H/PPMContext.cs +++ b/src/SharpCompress/Compressors/PPMd/H/PPMContext.cs @@ -548,5 +548,8 @@ internal class PpmContext : Pointer return buffer.ToString(); } - static PpmContext() => UNION_SIZE = Math.Max(FreqData.SIZE, State.SIZE); + static PpmContext() + { + UNION_SIZE = Math.Max(FreqData.SIZE, State.SIZE); + } } diff --git a/src/SharpCompress/Compressors/PPMd/H/Pointer.cs b/src/SharpCompress/Compressors/PPMd/H/Pointer.cs index 96cf4c3e..f5fd1b9f 100644 --- a/src/SharpCompress/Compressors/PPMd/H/Pointer.cs +++ b/src/SharpCompress/Compressors/PPMd/H/Pointer.cs @@ -7,7 +7,10 @@ internal abstract class Pointer /// Initialize the object with the array (may be null) /// the byte array /// - internal Pointer(byte[] mem) => Memory = mem; + internal Pointer(byte[] mem) + { + Memory = mem; + } internal byte[] Memory { get; private set; } diff --git a/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs b/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs index e507f3c3..a5c64846 100644 --- a/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs +++ b/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs @@ -77,7 +77,10 @@ internal class SubAllocator private RarMemBlock _tempRarMemBlock2; private RarMemBlock _tempRarMemBlock3; - public SubAllocator() => Clean(); + public SubAllocator() + { + Clean(); + } public virtual void Clean() => _subAllocatorSize = 0; @@ -438,5 +441,8 @@ internal class SubAllocator return buffer.ToString(); } - static SubAllocator() => UNIT_SIZE = Math.Max(PpmContext.SIZE, RarMemBlock.SIZE); + static SubAllocator() + { + UNIT_SIZE = Math.Max(PpmContext.SIZE, RarMemBlock.SIZE); + } } diff --git a/src/SharpCompress/Compressors/PPMd/I1/Allocator.cs b/src/SharpCompress/Compressors/PPMd/I1/Allocator.cs index c4d8aa4b..f15e16cb 100644 --- a/src/SharpCompress/Compressors/PPMd/I1/Allocator.cs +++ b/src/SharpCompress/Compressors/PPMd/I1/Allocator.cs @@ -89,7 +89,10 @@ internal class Allocator #region Public Methods - public Allocator() => _memoryNodes = new MemoryNode[INDEX_COUNT]; + public Allocator() + { + _memoryNodes = new MemoryNode[INDEX_COUNT]; + } /// /// Initialize or reset the memory allocator (so that the single, large array can be re-used without destroying diff --git a/src/SharpCompress/Compressors/PPMd/I1/MemoryNode.cs b/src/SharpCompress/Compressors/PPMd/I1/MemoryNode.cs index c8b411d8..f5b1631b 100644 --- a/src/SharpCompress/Compressors/PPMd/I1/MemoryNode.cs +++ b/src/SharpCompress/Compressors/PPMd/I1/MemoryNode.cs @@ -1,5 +1,7 @@ #nullable disable +using System; + namespace SharpCompress.Compressors.PPMd.I1; /// @@ -23,7 +25,7 @@ namespace SharpCompress.Compressors.PPMd.I1; /// Note that is a field rather than a property for performance reasons. /// /// -internal struct MemoryNode +internal struct MemoryNode : IEquatable { public uint _address; public byte[] _memory; @@ -232,6 +234,8 @@ internal struct MemoryNode return base.Equals(obj); } + public readonly bool Equals(MemoryNode other) => other._address == _address; + /// /// Returns the hash code for this instance. /// diff --git a/src/SharpCompress/Compressors/PPMd/I1/Pointer.cs b/src/SharpCompress/Compressors/PPMd/I1/Pointer.cs index d1a89545..a60a1063 100644 --- a/src/SharpCompress/Compressors/PPMd/I1/Pointer.cs +++ b/src/SharpCompress/Compressors/PPMd/I1/Pointer.cs @@ -18,7 +18,7 @@ namespace SharpCompress.Compressors.PPMd.I1; /// Note that is a field rather than a property for performance reasons. /// /// -internal struct Pointer +internal struct Pointer : IEquatable { public uint _address; public byte[] _memory; @@ -349,6 +349,8 @@ internal struct Pointer return base.Equals(obj); } + public bool Equals(Pointer other) => other._address == _address; + /// /// Returns the hash code for this instance. /// diff --git a/src/SharpCompress/Compressors/PPMd/I1/PpmContext.cs b/src/SharpCompress/Compressors/PPMd/I1/PpmContext.cs index 701039c2..58a464a5 100644 --- a/src/SharpCompress/Compressors/PPMd/I1/PpmContext.cs +++ b/src/SharpCompress/Compressors/PPMd/I1/PpmContext.cs @@ -1,5 +1,7 @@ #nullable disable +using System; + namespace SharpCompress.Compressors.PPMd.I1; /// @@ -17,7 +19,7 @@ internal partial class Model /// /// The structure which represents the current PPM context. This is 12 bytes in size. /// - internal struct PpmContext + internal struct PpmContext : IEquatable { public uint _address; public byte[] _memory; @@ -262,6 +264,8 @@ internal partial class Model return base.Equals(obj); } + public bool Equals(PpmContext other) => other._address == _address; + /// /// Returns the hash code for this instance. /// @@ -577,7 +581,6 @@ internal partial class Model private See2Context MakeEscapeFrequency(PpmContext context) { - var numberStatistics = (uint)2 * context.NumberStatistics; See2Context see2Context; if (context.NumberStatistics != 0xff) @@ -585,7 +588,7 @@ internal partial class Model // Note that context.Flags is always in the range 0 .. 28 (this ensures that the index used for the second // dimension of the see2Contexts array is always in the range 0 .. 31). - numberStatistics = context.Suffix.NumberStatistics; + var numberStatistics = context.Suffix.NumberStatistics; var index1 = _probabilities[context.NumberStatistics + 2] - 3; var index2 = ((context.SummaryFrequency > 11 * (context.NumberStatistics + 1)) ? 1 : 0) diff --git a/src/SharpCompress/Compressors/PPMd/I1/PpmState.cs b/src/SharpCompress/Compressors/PPMd/I1/PpmState.cs index 02e79a34..f4c5f8f7 100644 --- a/src/SharpCompress/Compressors/PPMd/I1/PpmState.cs +++ b/src/SharpCompress/Compressors/PPMd/I1/PpmState.cs @@ -1,5 +1,7 @@ #nullable disable +using System; + namespace SharpCompress.Compressors.PPMd.I1; /// @@ -15,7 +17,7 @@ namespace SharpCompress.Compressors.PPMd.I1; /// Note that is a field rather than a property for performance reasons. /// /// -internal struct PpmState +internal struct PpmState : IEquatable { public uint _address; public byte[] _memory; @@ -183,6 +185,8 @@ internal struct PpmState return base.Equals(obj); } + public bool Equals(PpmState other) => other._address == _address; + /// /// Returns the hash code for this instance. /// diff --git a/src/SharpCompress/Compressors/RLE90/RunLength90Stream.cs b/src/SharpCompress/Compressors/RLE90/RunLength90Stream.cs index 165bfb54..c44283d0 100644 --- a/src/SharpCompress/Compressors/RLE90/RunLength90Stream.cs +++ b/src/SharpCompress/Compressors/RLE90/RunLength90Stream.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using SharpCompress.IO; namespace SharpCompress.Compressors.RLE90; diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Decode/AudioVariables.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Decode/AudioVariables.cs index ade62f55..9979ed60 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Decode/AudioVariables.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Decode/AudioVariables.cs @@ -2,7 +2,10 @@ namespace SharpCompress.Compressors.Rar.UnpackV1.Decode; internal class AudioVariables { - internal AudioVariables() => Dif = new int[11]; + internal AudioVariables() + { + Dif = new int[11]; + } internal int[] Dif { get; } internal int ByteCount { get; set; } diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs index e4e4769c..1e04f33a 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs @@ -18,9 +18,11 @@ internal sealed partial class Unpack : BitInput, IRarUnpack, IDisposable private readonly BitInput Inp; private bool disposed; - public Unpack() => - // to ease in porting Unpack50.cs - Inp = this; + public Unpack() + { + // to ease in porting Unpack50.cs + Inp = this; + } public void Dispose() { diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackFilter.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackFilter.cs index 5359ab24..502b2530 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackFilter.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackFilter.cs @@ -7,7 +7,10 @@ internal class UnpackFilter public byte Type; public byte Channels; - internal UnpackFilter() => Program = new VMPreparedProgram(); + internal UnpackFilter() + { + Program = new VMPreparedProgram(); + } // TODO uint internal uint uBlockStart diff --git a/src/SharpCompress/Compressors/Rar/UnpackV2017/FragmentedWindow.unpack50frag_cpp.cs b/src/SharpCompress/Compressors/Rar/UnpackV2017/FragmentedWindow.unpack50frag_cpp.cs index a9a6f280..502a6d1f 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV2017/FragmentedWindow.unpack50frag_cpp.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV2017/FragmentedWindow.unpack50frag_cpp.cs @@ -56,11 +56,6 @@ internal partial class FragmentedWindow while (Size >= MinSize) { NewMem = new byte[Size]; - if (NewMem != null) - { - break; - } - Size -= Size / 32; } diff --git a/src/SharpCompress/Compressors/Rar/UnpackV2017/unpack_hpp.cs b/src/SharpCompress/Compressors/Rar/UnpackV2017/unpack_hpp.cs index 05c96370..5f9cf76f 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV2017/unpack_hpp.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV2017/unpack_hpp.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using static SharpCompress.Compressors.Rar.UnpackV2017.PackDef; using static SharpCompress.Compressors.Rar.UnpackV2017.UnpackGlobal; diff --git a/src/SharpCompress/Compressors/Rar/VM/BitInput.cs b/src/SharpCompress/Compressors/Rar/VM/BitInput.cs index fe349fe7..f34d8da6 100644 --- a/src/SharpCompress/Compressors/Rar/VM/BitInput.cs +++ b/src/SharpCompress/Compressors/Rar/VM/BitInput.cs @@ -22,7 +22,10 @@ internal class BitInput public bool ExternalBuffer; /// - internal BitInput() => InBuf = new byte[MAX_SIZE]; + internal BitInput() + { + InBuf = new byte[MAX_SIZE]; + } internal byte[] InBuf { get; } diff --git a/src/SharpCompress/Compressors/Rar/VM/RarVM.cs b/src/SharpCompress/Compressors/Rar/VM/RarVM.cs index 745c16d1..0e5eec92 100644 --- a/src/SharpCompress/Compressors/Rar/VM/RarVM.cs +++ b/src/SharpCompress/Compressors/Rar/VM/RarVM.cs @@ -40,9 +40,11 @@ internal sealed class RarVM : BitInput private int IP; - internal RarVM() => - //InitBlock(); - Mem = null; + internal RarVM() + { + //InitBlock(); + Mem = null; + } internal void init() => Mem ??= new byte[VM_MEMSIZE + 4]; diff --git a/src/SharpCompress/Compressors/Reduce/ReduceStream.cs b/src/SharpCompress/Compressors/Reduce/ReduceStream.cs index ad159f1a..7fb30e2c 100644 --- a/src/SharpCompress/Compressors/Reduce/ReduceStream.cs +++ b/src/SharpCompress/Compressors/Reduce/ReduceStream.cs @@ -80,25 +80,13 @@ public class ReduceStream : Stream, IStreamStack base.Dispose(disposing); } - public override void Flush() - { - throw new NotImplementedException(); - } + public override void Flush() => throw new NotImplementedException(); - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotImplementedException(); - } + public override long Seek(long offset, SeekOrigin origin) => throw new NotImplementedException(); - public override void SetLength(long value) - { - throw new NotImplementedException(); - } + public override void SetLength(long value) => throw new NotImplementedException(); - public override void Write(byte[] buffer, int offset, int count) - { - throw new NotImplementedException(); - } + public override void Write(byte[] buffer, int offset, int count) => throw new NotImplementedException(); public override bool CanRead => true; public override bool CanSeek => false; diff --git a/src/SharpCompress/Compressors/Shrink/BitStream.cs b/src/SharpCompress/Compressors/Shrink/BitStream.cs index c8c3ca1a..8b657cf1 100644 --- a/src/SharpCompress/Compressors/Shrink/BitStream.cs +++ b/src/SharpCompress/Compressors/Shrink/BitStream.cs @@ -18,7 +18,7 @@ internal class BitStream 31U, 63U, (uint)sbyte.MaxValue, - (uint)byte.MaxValue, + byte.MaxValue, 511U, 1023U, 2047U, @@ -26,7 +26,7 @@ internal class BitStream 8191U, 16383U, (uint)short.MaxValue, - (uint)ushort.MaxValue + ushort.MaxValue ]; public BitStream(byte[] src, int srcLen) diff --git a/src/SharpCompress/Compressors/Shrink/HwUnshrink.cs b/src/SharpCompress/Compressors/Shrink/HwUnshrink.cs index 2367e2ac..31935bfd 100644 --- a/src/SharpCompress/Compressors/Shrink/HwUnshrink.cs +++ b/src/SharpCompress/Compressors/Shrink/HwUnshrink.cs @@ -2,7 +2,7 @@ using System; namespace SharpCompress.Compressors.Shrink; -public class HwUnshrink +public static class HwUnshrink { private const int MIN_CODE_SIZE = 9; private const int MAX_CODE_SIZE = 13; diff --git a/src/SharpCompress/Compressors/Squeezed/SqueezedStream.cs b/src/SharpCompress/Compressors/Squeezed/SqueezedStream.cs index f60b415a..de03cf41 100644 --- a/src/SharpCompress/Compressors/Squeezed/SqueezedStream.cs +++ b/src/SharpCompress/Compressors/Squeezed/SqueezedStream.cs @@ -2,8 +2,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Threading.Tasks; using SharpCompress.Compressors.RLE90; using SharpCompress.IO; diff --git a/src/SharpCompress/Compressors/Xz/XZHeader.cs b/src/SharpCompress/Compressors/Xz/XZHeader.cs index 44af20c2..4995c226 100644 --- a/src/SharpCompress/Compressors/Xz/XZHeader.cs +++ b/src/SharpCompress/Compressors/Xz/XZHeader.cs @@ -14,7 +14,10 @@ public class XZHeader public CheckType BlockCheckType { get; private set; } public int BlockCheckSize => 4 << ((((int)BlockCheckType + 2) / 3) - 1); - public XZHeader(BinaryReader reader) => _reader = reader; + public XZHeader(BinaryReader reader) + { + _reader = reader; + } public static XZHeader FromStream(Stream stream) { diff --git a/src/SharpCompress/Compressors/Xz/XZReadOnlyStream.cs b/src/SharpCompress/Compressors/Xz/XZReadOnlyStream.cs index 210478d6..fa540b64 100644 --- a/src/SharpCompress/Compressors/Xz/XZReadOnlyStream.cs +++ b/src/SharpCompress/Compressors/Xz/XZReadOnlyStream.cs @@ -26,7 +26,7 @@ public abstract class XZReadOnlyStream : ReadOnlyStream, IStreamStack void IStreamStack.SetPosition(long position) { } - public XZReadOnlyStream(Stream stream) + protected XZReadOnlyStream(Stream stream) { BaseStream = stream; if (!BaseStream.CanRead) diff --git a/src/SharpCompress/Compressors/ZStandard/ZStandardStream.cs b/src/SharpCompress/Compressors/ZStandard/ZStandardStream.cs index 61f7fbb4..35ca8267 100644 --- a/src/SharpCompress/Compressors/ZStandard/ZStandardStream.cs +++ b/src/SharpCompress/Compressors/ZStandard/ZStandardStream.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using SharpCompress.IO; namespace SharpCompress.Compressors.ZStandard; @@ -59,7 +55,7 @@ internal class ZStandardStream : ZstdSharp.DecompressionStream, IStreamStack /// Attempting to set the position public override long Position { - get { return stream.Position; } - set { throw new NotSupportedException("InflaterInputStream Position not supported"); } + get => stream.Position; + set => throw new NotSupportedException("InflaterInputStream Position not supported"); } } diff --git a/src/SharpCompress/Compressors/ZStandard/ZstandardConstants.cs b/src/SharpCompress/Compressors/ZStandard/ZstandardConstants.cs index 8025c658..ac4756d4 100644 --- a/src/SharpCompress/Compressors/ZStandard/ZstandardConstants.cs +++ b/src/SharpCompress/Compressors/ZStandard/ZstandardConstants.cs @@ -1,9 +1,3 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - namespace SharpCompress.Compressors.ZStandard; internal class ZstandardConstants diff --git a/src/SharpCompress/Factories/ArcFactory.cs b/src/SharpCompress/Factories/ArcFactory.cs index ea0617ee..707fdeb8 100644 --- a/src/SharpCompress/Factories/ArcFactory.cs +++ b/src/SharpCompress/Factories/ArcFactory.cs @@ -1,14 +1,8 @@ -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Security.Cryptography; -using System.Text; -using System.Threading.Tasks; using SharpCompress.Common; using SharpCompress.Readers; using SharpCompress.Readers.Arc; -using static System.Net.Mime.MediaTypeNames; namespace SharpCompress.Factories; diff --git a/src/SharpCompress/Factories/ZStandardFactory.cs b/src/SharpCompress/Factories/ZStandardFactory.cs index a5c6d84f..1e79508c 100644 --- a/src/SharpCompress/Factories/ZStandardFactory.cs +++ b/src/SharpCompress/Factories/ZStandardFactory.cs @@ -1,12 +1,6 @@ -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using SharpCompress.Archives; using SharpCompress.Compressors.ZStandard; -using SharpCompress.Readers; namespace SharpCompress.Factories; diff --git a/src/SharpCompress/IO/ReadOnlySubStream.cs b/src/SharpCompress/IO/ReadOnlySubStream.cs index ffcd55fd..142fd2e3 100644 --- a/src/SharpCompress/IO/ReadOnlySubStream.cs +++ b/src/SharpCompress/IO/ReadOnlySubStream.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.IO; namespace SharpCompress.IO; diff --git a/src/SharpCompress/IO/SharpCompressStream.cs b/src/SharpCompress/IO/SharpCompressStream.cs index 1e0c3d61..ea9bf022 100644 --- a/src/SharpCompress/IO/SharpCompressStream.cs +++ b/src/SharpCompress/IO/SharpCompressStream.cs @@ -1,8 +1,5 @@ using System; -using System.Diagnostics; using System.IO; -using System.Text; -using System.Threading; namespace SharpCompress.IO; @@ -137,7 +134,7 @@ public class SharpCompressStream : Stream, IStreamStack this.ThrowOnDispose = throwOnDispose; _readOnly = !Stream.CanSeek; - ((IStreamStack)this).SetBuffer(bufferSize, forceBuffer); + this.SetBuffer(bufferSize, forceBuffer); try { _baseInitialPos = stream.Position; @@ -188,15 +185,9 @@ public class SharpCompressStream : Stream, IStreamStack public override bool CanWrite => !_readOnly && Stream.CanWrite; - public override void Flush() - { - Stream.Flush(); - } + public override void Flush() => Stream.Flush(); - public override long Length - { - get { return Stream.Length; } - } + public override long Length => Stream.Length; public override long Position { @@ -205,7 +196,7 @@ public class SharpCompressStream : Stream, IStreamStack long pos = _internalPosition; // Stream.Position + _bufferStream.Position - _bufferStream.Length; return pos; } - set { Seek(value, SeekOrigin.Begin); } + set => Seek(value, SeekOrigin.Begin); } public override int Read(byte[] buffer, int offset, int count) @@ -310,10 +301,7 @@ public class SharpCompressStream : Stream, IStreamStack return _internalPosition; } - public override void SetLength(long value) - { - throw new NotSupportedException(); - } + public override void SetLength(long value) => throw new NotSupportedException(); public override void WriteByte(byte value) { diff --git a/src/SharpCompress/IO/StackStreamExtensions.cs b/src/SharpCompress/IO/StackStreamExtensions.cs index 4f3ce403..6eacc2d4 100644 --- a/src/SharpCompress/IO/StackStreamExtensions.cs +++ b/src/SharpCompress/IO/StackStreamExtensions.cs @@ -273,12 +273,10 @@ internal static class StackStreamExtensions /// /// The stream stack. /// The debug message to write. - public static void DebugTrace(this IStreamStack stream, string message) - { - Debug.WriteLine( - $"{GetStreamStackString(stream, false)} : [{stream.GetType().Name}]{message}" - ); - } + public static void DebugTrace(this IStreamStack stream, string message) => + Debug.WriteLine( + $"{GetStreamStackString(stream, false)} : [{stream.GetType().Name}]{message}" + ); /// /// Returns the full stream chain as a string, including instance IDs and positions. diff --git a/src/SharpCompress/LazyReadOnlyCollection.cs b/src/SharpCompress/LazyReadOnlyCollection.cs index 94f07e63..de6dc541 100644 --- a/src/SharpCompress/LazyReadOnlyCollection.cs +++ b/src/SharpCompress/LazyReadOnlyCollection.cs @@ -12,7 +12,10 @@ internal sealed class LazyReadOnlyCollection : ICollection private readonly IEnumerator source; private bool fullyLoaded; - public LazyReadOnlyCollection(IEnumerable source) => this.source = source.GetEnumerator(); + public LazyReadOnlyCollection(IEnumerable source) + { + this.source = source.GetEnumerator(); + } private class LazyLoader : IEnumerator { @@ -20,8 +23,10 @@ internal sealed class LazyReadOnlyCollection : ICollection private bool disposed; private int index = -1; - internal LazyLoader(LazyReadOnlyCollection lazyReadOnlyCollection) => - this.lazyReadOnlyCollection = lazyReadOnlyCollection; + internal LazyLoader(LazyReadOnlyCollection lazyReadOnlyCollection) + { + this.lazyReadOnlyCollection = lazyReadOnlyCollection; + } #region IEnumerator Members diff --git a/src/SharpCompress/NotNullExtensions.cs b/src/SharpCompress/NotNullExtensions.cs index 8cbbb528..66c55da4 100644 --- a/src/SharpCompress/NotNullExtensions.cs +++ b/src/SharpCompress/NotNullExtensions.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Linq; using System.Runtime.CompilerServices; namespace SharpCompress.Helpers; diff --git a/src/SharpCompress/Readers/Arc/ArcReader.cs b/src/SharpCompress/Readers/Arc/ArcReader.cs index 760f6345..daed3a49 100644 --- a/src/SharpCompress/Readers/Arc/ArcReader.cs +++ b/src/SharpCompress/Readers/Arc/ArcReader.cs @@ -1,9 +1,5 @@ -using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using SharpCompress.Common; using SharpCompress.Common.Arc; @@ -12,7 +8,10 @@ namespace SharpCompress.Readers.Arc; public class ArcReader : AbstractReader { private ArcReader(Stream stream, ReaderOptions options) - : base(options, ArchiveType.Arc) => Volume = new ArcVolume(stream, options, 0); + : base(options, ArchiveType.Arc) + { + Volume = new ArcVolume(stream, options, 0); + } public override ArcVolume Volume { get; } diff --git a/src/SharpCompress/Readers/GZip/GZipReader.cs b/src/SharpCompress/Readers/GZip/GZipReader.cs index 73bc4a9d..b2c47ed6 100644 --- a/src/SharpCompress/Readers/GZip/GZipReader.cs +++ b/src/SharpCompress/Readers/GZip/GZipReader.cs @@ -8,7 +8,10 @@ namespace SharpCompress.Readers.GZip; public class GZipReader : AbstractReader { private GZipReader(Stream stream, ReaderOptions options) - : base(options, ArchiveType.GZip) => Volume = new GZipVolume(stream, options, 0); + : base(options, ArchiveType.GZip) + { + Volume = new GZipVolume(stream, options, 0); + } public override GZipVolume Volume { get; } diff --git a/src/SharpCompress/Readers/Rar/MultiVolumeRarReader.cs b/src/SharpCompress/Readers/Rar/MultiVolumeRarReader.cs index 556ca9f5..db3f9e8a 100644 --- a/src/SharpCompress/Readers/Rar/MultiVolumeRarReader.cs +++ b/src/SharpCompress/Readers/Rar/MultiVolumeRarReader.cs @@ -15,7 +15,10 @@ internal class MultiVolumeRarReader : RarReader private Stream tempStream; internal MultiVolumeRarReader(IEnumerable streams, ReaderOptions options) - : base(options) => this.streams = streams.GetEnumerator(); + : base(options) + { + this.streams = streams.GetEnumerator(); + } protected override void ValidateArchive(RarVolume archive) { } diff --git a/src/SharpCompress/Readers/Rar/SingleVolumeRarReader.cs b/src/SharpCompress/Readers/Rar/SingleVolumeRarReader.cs index 165c92f7..5c6685e2 100644 --- a/src/SharpCompress/Readers/Rar/SingleVolumeRarReader.cs +++ b/src/SharpCompress/Readers/Rar/SingleVolumeRarReader.cs @@ -9,7 +9,10 @@ internal class SingleVolumeRarReader : RarReader private readonly Stream stream; internal SingleVolumeRarReader(Stream stream, ReaderOptions options) - : base(options) => this.stream = stream; + : base(options) + { + this.stream = stream; + } protected override void ValidateArchive(RarVolume archive) { diff --git a/src/SharpCompress/Writers/Tar/TarWriterOptions.cs b/src/SharpCompress/Writers/Tar/TarWriterOptions.cs index 8f2e866d..6525ee81 100755 --- a/src/SharpCompress/Writers/Tar/TarWriterOptions.cs +++ b/src/SharpCompress/Writers/Tar/TarWriterOptions.cs @@ -10,8 +10,14 @@ public class TarWriterOptions : WriterOptions public bool FinalizeArchiveOnClose { get; } public TarWriterOptions(CompressionType compressionType, bool finalizeArchiveOnClose) - : base(compressionType) => FinalizeArchiveOnClose = finalizeArchiveOnClose; + : base(compressionType) + { + FinalizeArchiveOnClose = finalizeArchiveOnClose; + } internal TarWriterOptions(WriterOptions options) - : this(options.CompressionType, true) => ArchiveEncoding = options.ArchiveEncoding; + : this(options.CompressionType, true) + { + ArchiveEncoding = options.ArchiveEncoding; + } } diff --git a/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs b/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs index 524ea7eb..a0a65342 100644 --- a/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs +++ b/src/SharpCompress/Writers/Zip/ZipWriterOptions.cs @@ -32,10 +32,7 @@ public class ZipWriterOptions : WriterOptions /// This is a convenience method that sets the CompressionLevel property for Deflate compression. /// /// Deflate compression level (0=no compression, 6=default, 9=best compression) - public void SetDeflateCompressionLevel(CompressionLevel level) - { - CompressionLevel = (int)level; - } + public void SetDeflateCompressionLevel(CompressionLevel level) => CompressionLevel = (int)level; /// /// Sets the compression level for ZStandard compression (1-22).