more clean up

This commit is contained in:
Adam Hathcock
2024-03-14 09:00:44 +00:00
parent 94d1503c64
commit 198a0673a2
53 changed files with 254 additions and 296 deletions

View File

@@ -31,10 +31,10 @@ public abstract class AbstractWritableArchive<TEntry, TVolume>
}
}
private readonly List<TEntry> newEntries = new List<TEntry>();
private readonly List<TEntry> removedEntries = new List<TEntry>();
private readonly List<TEntry> newEntries = new();
private readonly List<TEntry> removedEntries = new();
private readonly List<TEntry> modifiedEntries = new List<TEntry>();
private readonly List<TEntry> modifiedEntries = new();
private bool hasModifications;
private bool pauseRebuilding;

View File

@@ -94,7 +94,7 @@ public class GZipArchive : AbstractWritableArchive<GZipArchiveEntry, GZipVolume>
);
}
public static GZipArchive Create() => new GZipArchive();
public static GZipArchive Create() => new();
/// <summary>
/// Constructor with a SourceStream able to handle FileInfo and Streams.

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -13,10 +14,8 @@ namespace SharpCompress.Archives.Rar;
public class RarArchive : AbstractArchive<RarArchiveEntry, RarVolume>
{
internal Lazy<IRarUnpack> UnpackV2017 { get; } =
new Lazy<IRarUnpack>(() => new Compressors.Rar.UnpackV2017.Unpack());
internal Lazy<IRarUnpack> UnpackV1 { get; } =
new Lazy<IRarUnpack>(() => new Compressors.Rar.UnpackV1.Unpack());
internal Lazy<IRarUnpack> UnpackV2017 { get; } = new(() => new Compressors.Rar.UnpackV2017.Unpack());
internal Lazy<IRarUnpack> UnpackV1 { get; } = new(() => new Compressors.Rar.UnpackV1.Unpack());
/// <summary>
/// Constructor with a SourceStream able to handle FileInfo and Streams.

View File

@@ -195,7 +195,7 @@ public class TarArchive : AbstractWritableArchive<TarArchiveEntry, TarVolume>
}
}
public static TarArchive Create() => new TarArchive();
public static TarArchive Create() => new();
protected override TarArchiveEntry CreateEntryInternal(
string filePath,

View File

@@ -294,7 +294,7 @@ public class ZipArchive : AbstractWritableArchive<ZipArchiveEntry, ZipVolume>
bool closeStream
) => new ZipWritableArchiveEntry(this, source, filePath, size, modified, closeStream);
public static ZipArchive Create() => new ZipArchive();
public static ZipArchive Create() => new();
protected override IReader CreateReaderForSolidExtraction()
{

View File

@@ -7,5 +7,5 @@ public class OptionsBase
/// </summary>
public bool LeaveStreamOpen { get; set; } = true;
public ArchiveEncoding ArchiveEncoding { get; set; } = new ArchiveEncoding();
public ArchiveEncoding ArchiveEncoding { get; set; } = new();
}

View File

@@ -12,7 +12,7 @@ internal class ArchiveCryptHeader : RarHeader
public ArchiveCryptHeader(RarHeader header, RarCrcBinaryReader reader)
: base(header, reader, HeaderType.Crypt) { }
public Rar5CryptoInfo CryptInfo = new Rar5CryptoInfo();
public Rar5CryptoInfo CryptInfo = new();
protected override void ReadFinish(MarkingBinaryReader reader)
{

View File

@@ -10,7 +10,7 @@ namespace SharpCompress.Common.Rar;
internal sealed class RarCryptoBinaryReader : RarCrcBinaryReader
{
private BlockTransformer _rijndael;
private readonly Queue<byte> _data = new Queue<byte>();
private readonly Queue<byte> _data = new();
private long _readCount;
public RarCryptoBinaryReader(Stream stream, ICryptKey cryptKey)

View File

@@ -9,7 +9,7 @@ internal sealed class RarCryptoWrapper : Stream
{
private readonly Stream _actualStream;
private BlockTransformer _rijndael;
private readonly Queue<byte> _data = new Queue<byte>();
private readonly Queue<byte> _data = new();
public RarCryptoWrapper(Stream actualStream, byte[] salt, ICryptKey key)
{

View File

@@ -15,15 +15,15 @@ internal class ArchiveDatabase
internal long _startPositionAfterHeader;
internal long _dataStartPosition;
internal List<long> _packSizes = new List<long>();
internal List<uint?> _packCrCs = new List<uint?>();
internal List<CFolder> _folders = new List<CFolder>();
internal List<long> _packSizes = new();
internal List<uint?> _packCrCs = new();
internal List<CFolder> _folders = new();
internal List<int> _numUnpackStreamsVector;
internal List<CFileItem> _files = new List<CFileItem>();
internal List<CFileItem> _files = new();
internal List<long> _packStreamStartPositions = new List<long>();
internal List<int> _folderStartFileIndex = new List<int>();
internal List<int> _fileIndexToFolderIndexMap = new List<int>();
internal List<long> _packStreamStartPositions = new();
internal List<int> _folderStartFileIndex = new();
internal List<int> _fileIndexToFolderIndexMap = new();
internal IPasswordProvider PasswordProvider { get; }

View File

@@ -14,13 +14,13 @@ namespace SharpCompress.Common.SevenZip;
internal class ArchiveReader
{
internal Stream _stream;
internal Stack<DataReader> _readerStack = new Stack<DataReader>();
internal Stack<DataReader> _readerStack = new();
internal DataReader _currentReader;
internal long _streamOrigin;
internal long _streamEnding;
internal byte[] _header;
private readonly Dictionary<int, Stream> _cachedStreams = new Dictionary<int, Stream>();
private readonly Dictionary<int, Stream> _cachedStreams = new();
internal void AddByteStream(byte[] buffer, int offset, int length)
{
@@ -1359,7 +1359,7 @@ internal class ArchiveReader
{
internal int _fileIndex;
internal int _folderIndex;
internal List<bool> _extractStatuses = new List<bool>();
internal List<bool> _extractStatuses = new();
internal CExtractFolderInfo(int fileIndex, int folderIndex)
{

View File

@@ -6,11 +6,11 @@ namespace SharpCompress.Common.SevenZip;
internal class CFolder
{
internal List<CCoderInfo> _coders = new List<CCoderInfo>();
internal List<CBindPair> _bindPairs = new List<CBindPair>();
internal List<int> _packStreams = new List<int>();
internal List<CCoderInfo> _coders = new();
internal List<CBindPair> _bindPairs = new();
internal List<int> _packStreams = new();
internal int _firstPackStreamId;
internal List<long> _unpackSizes = new List<long>();
internal List<long> _unpackSizes = new();
internal uint? _unpackCrc;
internal bool UnpackCrcDefined => _unpackCrc != null;

View File

@@ -7,10 +7,10 @@ internal readonly struct CMethodId
public const ulong K_LZMA2_ID = 0x21;
public const ulong K_AES_ID = 0x06F10701;
public static readonly CMethodId K_COPY = new CMethodId(K_COPY_ID);
public static readonly CMethodId K_LZMA = new CMethodId(K_LZMA_ID);
public static readonly CMethodId K_LZMA2 = new CMethodId(K_LZMA2_ID);
public static readonly CMethodId K_AES = new CMethodId(K_AES_ID);
public static readonly CMethodId K_COPY = new(K_COPY_ID);
public static readonly CMethodId K_LZMA = new(K_LZMA_ID);
public static readonly CMethodId K_LZMA2 = new(K_LZMA2_ID);
public static readonly CMethodId K_AES = new(K_AES_ID);
public readonly ulong _id;

View File

@@ -9,7 +9,7 @@ namespace SharpCompress.Common.Tar.Headers;
internal sealed class TarHeader
{
internal static readonly DateTime EPOCH = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
internal static readonly DateTime EPOCH = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
public TarHeader(ArchiveEncoding archiveEncoding) => ArchiveEncoding = archiveEncoding;

View File

@@ -6,7 +6,7 @@ namespace SharpCompress.Common.Zip;
internal class PkwareTraditionalEncryptionData
{
private static readonly CRC32 CRC32 = new CRC32();
private static readonly CRC32 CRC32 = new();
private readonly uint[] _keys = { 0x12345678, 0x23456789, 0x34567890 };
private readonly ArchiveEncoding _archiveEncoding;

View File

@@ -87,7 +87,7 @@ internal class CBZip2InputStream : Stream
private int bsBuff;
private int bsLive;
private readonly CRC mCrc = new CRC();
private readonly CRC mCrc = new();
private readonly bool[] inUse = new bool[256];
private int nInUse;

View File

@@ -284,7 +284,7 @@ internal sealed class CBZip2OutputStream : Stream
private int bytesOut;
private int bsBuff;
private int bsLive;
private readonly CRC mCrc = new CRC();
private readonly CRC mCrc = new();
private readonly bool[] inUse = new bool[256];
private int nInUse;

View File

@@ -342,9 +342,9 @@ internal sealed partial class DeflateManager
private readonly short[] dyn_dtree; // distance tree
private readonly short[] bl_tree; // Huffman tree for bit lengths
private readonly Tree treeLiterals = new Tree(); // desc for literal tree
private readonly Tree treeDistances = new Tree(); // desc for distance tree
private readonly Tree treeBitLengths = new Tree(); // desc for bit length tree
private readonly Tree treeLiterals = new(); // desc for literal tree
private readonly Tree treeDistances = new(); // desc for distance tree
private readonly Tree treeBitLengths = new(); // desc for bit length tree
// number of codes at each bit length for an optimal tree
private readonly short[] bl_count = new short[InternalConstants.MAX_BITS + 1];

View File

@@ -366,9 +366,9 @@ public class DeflateStream : Stream
#endregion
public MemoryStream InputBuffer =>
new MemoryStream(
new(
_baseStream._z.InputBuffer,
_baseStream._z.NextIn,
_baseStream._z.AvailableBytesIn
);
);
}

View File

@@ -35,15 +35,15 @@ namespace SharpCompress.Compressors.Deflate;
public class GZipStream : Stream
{
internal static readonly DateTime UNIX_EPOCH = new DateTime(
1970,
1,
1,
0,
0,
0,
DateTimeKind.Utc
);
internal static readonly DateTime UNIX_EPOCH = new(
1970,
1,
1,
0,
0,
0,
DateTimeKind.Utc
);
private string? _comment;
private string? _fileName;

View File

@@ -105,11 +105,11 @@ internal sealed class InflateBlocks
internal int[] blens; // bit lengths of codes
internal uint check; // check on output
internal object checkfn; // check function
internal InflateCodes codes = new InflateCodes(); // if CODES, current state
internal InflateCodes codes = new(); // if CODES, current state
internal int end; // one byte after sliding window
internal int[] hufts; // single malloc for tree space
internal int index; // index into blens (or border)
internal InfTree inftree = new InfTree();
internal InfTree inftree = new();
internal int last; // true if this block is the last block
internal int left; // if STORED, bytes left to copy
private InflateBlockMode mode; // current inflate_block mode

View File

@@ -22,7 +22,7 @@ internal sealed class DeflateInput
Debug.Assert(StartIndex + Count <= Buffer.Length, "Input buffer is in invalid state!");
}
internal InputState DumpState() => new InputState(Count, StartIndex);
internal InputState DumpState() => new(Count, StartIndex);
internal void RestoreState(InputState state)
{

View File

@@ -42,11 +42,9 @@ internal sealed class HuffmanTree
private readonly int _tableMask;
// huffman tree for static block
public static HuffmanTree StaticLiteralLengthTree { get; } =
new HuffmanTree(GetStaticLiteralTreeLength());
public static HuffmanTree StaticLiteralLengthTree { get; } = new(GetStaticLiteralTreeLength());
public static HuffmanTree StaticDistanceTree { get; } =
new HuffmanTree(GetStaticDistanceTreeLength());
public static HuffmanTree StaticDistanceTree { get; } = new(GetStaticDistanceTreeLength());
public HuffmanTree(byte[] codeLengths)
{

View File

@@ -6,7 +6,7 @@ namespace SharpCompress.Compressors.LZMA;
internal static class Log
{
private static readonly Stack<string> INDENT = new Stack<string>();
private static readonly Stack<string> INDENT = new();
private static bool NEEDS_INDENT = true;
static Log() => INDENT.Push("");

View File

@@ -11,11 +11,11 @@ public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream
{
private class LenDecoder
{
private BitDecoder _choice = new BitDecoder();
private BitDecoder _choice2 = new BitDecoder();
private BitDecoder _choice = new();
private BitDecoder _choice2 = new();
private readonly BitTreeDecoder[] _lowCoder = new BitTreeDecoder[Base.K_NUM_POS_STATES_MAX];
private readonly BitTreeDecoder[] _midCoder = new BitTreeDecoder[Base.K_NUM_POS_STATES_MAX];
private BitTreeDecoder _highCoder = new BitTreeDecoder(Base.K_NUM_HIGH_LEN_BITS);
private BitTreeDecoder _highCoder = new(Base.K_NUM_HIGH_LEN_BITS);
private uint _numPosStates;
public void Create(uint numPosStates)
@@ -173,18 +173,18 @@ public class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream
Base.K_NUM_FULL_DISTANCES - Base.K_END_POS_MODEL_INDEX
];
private BitTreeDecoder _posAlignDecoder = new BitTreeDecoder(Base.K_NUM_ALIGN_BITS);
private BitTreeDecoder _posAlignDecoder = new(Base.K_NUM_ALIGN_BITS);
private readonly LenDecoder _lenDecoder = new LenDecoder();
private readonly LenDecoder _repLenDecoder = new LenDecoder();
private readonly LenDecoder _lenDecoder = new();
private readonly LenDecoder _repLenDecoder = new();
private readonly LiteralDecoder _literalDecoder = new LiteralDecoder();
private readonly LiteralDecoder _literalDecoder = new();
private int _dictionarySize;
private uint _posStateMask;
private Base.State _state = new Base.State();
private Base.State _state = new();
private uint _rep0,
_rep1,
_rep2,

View File

@@ -61,7 +61,7 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
return (uint)(G_FAST_POS[pos >> 26] + 52);
}
private Base.State _state = new Base.State();
private Base.State _state = new();
private byte _previousByte;
private readonly uint[] _repDistances = new uint[Base.K_NUM_REP_DISTANCES];
@@ -191,15 +191,15 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
private class LenEncoder
{
private BitEncoder _choice = new BitEncoder();
private BitEncoder _choice2 = new BitEncoder();
private BitEncoder _choice = new();
private BitEncoder _choice2 = new();
private readonly BitTreeEncoder[] _lowCoder = new BitTreeEncoder[
Base.K_NUM_POS_STATES_ENCODING_MAX
];
private readonly BitTreeEncoder[] _midCoder = new BitTreeEncoder[
Base.K_NUM_POS_STATES_ENCODING_MAX
];
private BitTreeEncoder _highCoder = new BitTreeEncoder(Base.K_NUM_HIGH_LEN_BITS);
private BitTreeEncoder _highCoder = new(Base.K_NUM_HIGH_LEN_BITS);
public LenEncoder()
{
@@ -359,7 +359,7 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
private readonly Optimal[] _optimum = new Optimal[K_NUM_OPTS];
private BinTree _matchFinder;
private readonly RangeCoder.Encoder _rangeEncoder = new RangeCoder.Encoder();
private readonly RangeCoder.Encoder _rangeEncoder = new();
private readonly BitEncoder[] _isMatch = new BitEncoder[
Base.K_NUM_STATES << Base.K_NUM_POS_STATES_BITS_MAX
@@ -382,12 +382,12 @@ internal class Encoder : ICoder, ISetCoderProperties, IWriteCoderProperties
Base.K_NUM_FULL_DISTANCES - Base.K_END_POS_MODEL_INDEX
];
private BitTreeEncoder _posAlignEncoder = new BitTreeEncoder(Base.K_NUM_ALIGN_BITS);
private BitTreeEncoder _posAlignEncoder = new(Base.K_NUM_ALIGN_BITS);
private readonly LenPriceTableEncoder _lenEncoder = new LenPriceTableEncoder();
private readonly LenPriceTableEncoder _repMatchLenEncoder = new LenPriceTableEncoder();
private readonly LenPriceTableEncoder _lenEncoder = new();
private readonly LenPriceTableEncoder _repMatchLenEncoder = new();
private readonly LiteralEncoder _literalEncoder = new LiteralEncoder();
private readonly LiteralEncoder _literalEncoder = new();
private readonly uint[] _matchDistances = new uint[(Base.K_MATCH_MAX_LEN * 2) + 2];

View File

@@ -14,8 +14,8 @@ public class LzmaStream : Stream
private readonly long _outputSize;
private readonly int _dictionarySize;
private readonly OutWindow _outWindow = new OutWindow();
private readonly RangeCoder.Decoder _rangeDecoder = new RangeCoder.Decoder();
private readonly OutWindow _outWindow = new();
private readonly RangeCoder.Decoder _rangeDecoder = new();
private Decoder _decoder;
private long _position;

View File

@@ -22,7 +22,7 @@ internal class ModelPpm
}
}
public SubAllocator SubAlloc { get; } = new SubAllocator();
public SubAllocator SubAlloc { get; } = new();
public virtual See2Context DummySee2Cont => _dummySee2Cont;
@@ -137,34 +137,34 @@ internal class ModelPpm
// Temp fields
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState1 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState1 = new State(null);
private readonly State _tempState1 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState2 = new State(null);
private readonly State _tempState2 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState3 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState3 = new State(null);
private readonly State _tempState3 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState4 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState4 = new State(null);
private readonly State _tempState4 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempStateRef1 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly StateRef _tempStateRef1 = new StateRef();
private readonly StateRef _tempStateRef1 = new();
//UPGRADE_NOTE: Final was removed from the declaration of 'tempStateRef2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly StateRef _tempStateRef2 = new StateRef();
private readonly StateRef _tempStateRef2 = new();
//UPGRADE_NOTE: Final was removed from the declaration of 'tempPPMContext1 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly PpmContext _tempPpmContext1 = new PpmContext(null);
private readonly PpmContext _tempPpmContext1 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempPPMContext2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly PpmContext _tempPpmContext2 = new PpmContext(null);
private readonly PpmContext _tempPpmContext2 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempPPMContext3 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly PpmContext _tempPpmContext3 = new PpmContext(null);
private readonly PpmContext _tempPpmContext3 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempPPMContext4 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly PpmContext _tempPpmContext4 = new PpmContext(null);
private readonly PpmContext _tempPpmContext4 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'ps '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly int[] _ps = new int[MAX_O];

View File

@@ -64,19 +64,19 @@ internal class PpmContext : Pointer
// Temp fields
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState1 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState1 = new State(null);
private readonly State _tempState1 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState2 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState2 = new State(null);
private readonly State _tempState2 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState3 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState3 = new State(null);
private readonly State _tempState3 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState4 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState4 = new State(null);
private readonly State _tempState4 = new(null);
//UPGRADE_NOTE: Final was removed from the declaration of 'tempState5 '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
private readonly State _tempState5 = new State(null);
private readonly State _tempState5 = new(null);
private PpmContext _tempPpmContext;
//UPGRADE_NOTE: Final was removed from the declaration of 'ps '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"

View File

@@ -27,7 +27,7 @@ internal struct MemoryNode
{
public uint _address;
public byte[] _memory;
public static readonly MemoryNode ZERO = new MemoryNode(0, null);
public static readonly MemoryNode ZERO = new(0, null);
public const int SIZE = 12;
/// <summary>
@@ -64,13 +64,13 @@ internal struct MemoryNode
public MemoryNode Next
{
get =>
new MemoryNode(
new(
_memory[_address + 4]
| (((uint)_memory[_address + 5]) << 8)
| (((uint)_memory[_address + 6]) << 16)
| (((uint)_memory[_address + 7]) << 24),
| (((uint)_memory[_address + 5]) << 8)
| (((uint)_memory[_address + 6]) << 16)
| (((uint)_memory[_address + 7]) << 24),
_memory
);
);
set
{
_memory[_address + 4] = (byte)value._address;
@@ -150,7 +150,7 @@ internal struct MemoryNode
/// <param name="pointer"></param>
/// <returns></returns>
public static implicit operator MemoryNode(Pointer pointer) =>
new MemoryNode(pointer._address, pointer._memory);
new(pointer._address, pointer._memory);
/// <summary>
/// Allow pointer-like addition on a memory node.

View File

@@ -22,7 +22,7 @@ internal struct Pointer
{
public uint _address;
public byte[] _memory;
public static readonly Pointer ZERO = new Pointer(0, null);
public static readonly Pointer ZERO = new(0, null);
public const int SIZE = 1;
/// <summary>
@@ -69,7 +69,7 @@ internal struct Pointer
/// <param name="memoryNode"></param>
/// <returns></returns>
public static implicit operator Pointer(MemoryNode memoryNode) =>
new Pointer(memoryNode._address, memoryNode._memory);
new(memoryNode._address, memoryNode._memory);
/// <summary>
/// Allow a <see cref="Model.PpmContext"/> to be implicitly converted to a <see cref="Pointer"/>.
@@ -77,7 +77,7 @@ internal struct Pointer
/// <param name="context"></param>
/// <returns></returns>
public static implicit operator Pointer(Model.PpmContext context) =>
new Pointer(context._address, context._memory);
new(context._address, context._memory);
/// <summary>
/// Allow a <see cref="PpmState"/> to be implicitly converted to a <see cref="Pointer"/>.
@@ -85,7 +85,7 @@ internal struct Pointer
/// <param name="state"></param>
/// <returns></returns>
public static implicit operator Pointer(PpmState state) =>
new Pointer(state._address, state._memory);
new(state._address, state._memory);
/// <summary>
/// Increase the address of a pointer by the given number of bytes.

View File

@@ -21,7 +21,7 @@ internal partial class Model
{
public uint _address;
public byte[] _memory;
public static readonly PpmContext ZERO = new PpmContext(0, null);
public static readonly PpmContext ZERO = new(0, null);
public const int SIZE = 12;
/// <summary>
@@ -70,13 +70,13 @@ internal partial class Model
public PpmState Statistics
{
get =>
new PpmState(
new(
_memory[_address + 4]
| (((uint)_memory[_address + 5]) << 8)
| (((uint)_memory[_address + 6]) << 16)
| (((uint)_memory[_address + 7]) << 24),
| (((uint)_memory[_address + 5]) << 8)
| (((uint)_memory[_address + 6]) << 16)
| (((uint)_memory[_address + 7]) << 24),
_memory
);
);
set
{
_memory[_address + 4] = (byte)value._address;
@@ -92,13 +92,13 @@ internal partial class Model
public PpmContext Suffix
{
get =>
new PpmContext(
new(
_memory[_address + 8]
| (((uint)_memory[_address + 9]) << 8)
| (((uint)_memory[_address + 10]) << 16)
| (((uint)_memory[_address + 11]) << 24),
| (((uint)_memory[_address + 9]) << 8)
| (((uint)_memory[_address + 10]) << 16)
| (((uint)_memory[_address + 11]) << 24),
_memory
);
);
set
{
_memory[_address + 8] = (byte)value._address;
@@ -133,7 +133,7 @@ internal partial class Model
/// </para>
/// </remarks>
/// <returns></returns>
public PpmState FirstState => new PpmState(_address + 2, _memory);
public PpmState FirstState => new(_address + 2, _memory);
/// <summary>
/// Gets or sets the symbol of the first PPM state. This is provided for convenience. The same
@@ -164,13 +164,13 @@ internal partial class Model
public PpmContext FirstStateSuccessor
{
get =>
new PpmContext(
new(
_memory[_address + 4]
| (((uint)_memory[_address + 5]) << 8)
| (((uint)_memory[_address + 6]) << 16)
| (((uint)_memory[_address + 7]) << 24),
| (((uint)_memory[_address + 5]) << 8)
| (((uint)_memory[_address + 6]) << 16)
| (((uint)_memory[_address + 7]) << 24),
_memory
);
);
set
{
_memory[_address + 4] = (byte)value._address;
@@ -186,7 +186,7 @@ internal partial class Model
/// <param name="pointer"></param>
/// <returns></returns>
public static implicit operator PpmContext(Pointer pointer) =>
new PpmContext(pointer._address, pointer._memory);
new(pointer._address, pointer._memory);
/// <summary>
/// Allow pointer-like addition on a PPM context.

View File

@@ -19,7 +19,7 @@ internal struct PpmState
{
public uint _address;
public byte[] _memory;
public static readonly PpmState ZERO = new PpmState(0, null);
public static readonly PpmState ZERO = new(0, null);
public const int SIZE = 6;
/// <summary>
@@ -55,13 +55,13 @@ internal struct PpmState
public Model.PpmContext Successor
{
get =>
new Model.PpmContext(
new(
_memory[_address + 2]
| (((uint)_memory[_address + 3]) << 8)
| (((uint)_memory[_address + 4]) << 16)
| (((uint)_memory[_address + 5]) << 24),
| (((uint)_memory[_address + 3]) << 8)
| (((uint)_memory[_address + 4]) << 16)
| (((uint)_memory[_address + 5]) << 24),
_memory
);
);
set
{
_memory[_address + 2] = (byte)value._address;
@@ -77,7 +77,7 @@ internal struct PpmState
/// </summary>
/// <param name="offset"></param>
/// <returns></returns>
public PpmState this[int offset] => new PpmState((uint)(_address + (offset * SIZE)), _memory);
public PpmState this[int offset] => new((uint)(_address + (offset * SIZE)), _memory);
/// <summary>
/// Allow a pointer to be implicitly converted to a PPM state.
@@ -85,7 +85,7 @@ internal struct PpmState
/// <param name="pointer"></param>
/// <returns></returns>
public static implicit operator PpmState(Pointer pointer) =>
new PpmState(pointer._address, pointer._memory);
new(pointer._address, pointer._memory);
/// <summary>
/// Allow pointer-like addition on a PPM state.

View File

@@ -52,19 +52,19 @@ internal sealed partial class Unpack : BitInput, IRarUnpack
public int PpmEscChar { get; set; }
private readonly ModelPpm ppm = new ModelPpm();
private readonly ModelPpm ppm = new();
private readonly RarVM rarVM = new RarVM();
private readonly RarVM rarVM = new();
// Filters code, one entry per filter
private readonly List<UnpackFilter> filters = new List<UnpackFilter>();
private readonly List<UnpackFilter> filters = new();
// Filters stack, several entrances of same filter are possible
private readonly List<UnpackFilter> prgStack = new List<UnpackFilter>();
private readonly List<UnpackFilter> prgStack = new();
// lengths of preceding blocks, one length per filter. Used to reduce size
// required to write block length if lengths are repeating
private readonly List<int> oldFilterLengths = new List<int>();
private readonly List<int> oldFilterLengths = new();
private int lastFilter;

View File

@@ -25,15 +25,15 @@ internal partial class Unpack
private readonly AudioVariables[] AudV = new AudioVariables[4];
private readonly LitDecode LD = new LitDecode();
private readonly LitDecode LD = new();
private readonly DistDecode DD = new DistDecode();
private readonly DistDecode DD = new();
private readonly LowDistDecode LDD = new LowDistDecode();
private readonly LowDistDecode LDD = new();
private readonly RepDecode RD = new RepDecode();
private readonly RepDecode RD = new();
private readonly BitDecode BD = new BitDecode();
private readonly BitDecode BD = new();
private static readonly int[] LDecode =
{

View File

@@ -269,7 +269,7 @@ internal partial class Unpack
private byte[] FilterDstMemory = Array.Empty<byte>();
// Filters code, one entry per filter.
private readonly List<UnpackFilter> Filters = new List<UnpackFilter>();
private readonly List<UnpackFilter> Filters = new();
private readonly uint[] OldDist = new uint[4];
private uint OldDistPtr;
@@ -297,7 +297,7 @@ internal partial class Unpack
private byte[] Window;
private readonly FragmentedWindow FragWindow = new FragmentedWindow();
private readonly FragmentedWindow FragWindow = new();
private bool Fragmented;
private int64 DestUnpSize;
@@ -393,18 +393,18 @@ internal partial class Unpack
// Buffer to read VM filters code. We moved it here from AddVMCode
// function to reduce time spent in BitInput constructor.
private readonly BitInput VMCodeInp = new BitInput(true);
private readonly BitInput VMCodeInp = new(true);
// Filters code, one entry per filter.
private readonly List<UnpackFilter30> Filters30 = new List<UnpackFilter30>();
private readonly List<UnpackFilter30> Filters30 = new();
// Filters stack, several entrances of same filter are possible.
private readonly List<UnpackFilter30> PrgStack = new List<UnpackFilter30>();
private readonly List<UnpackFilter30> PrgStack = new();
// Lengths of preceding data blocks, one length of one last block
// for every filter. Used to reduce the size required to write
// the data block length if lengths are repeating.
private readonly List<int> OldFilterLengths = new List<int>();
private readonly List<int> OldFilterLengths = new();
/*#if RarV2017_RAR_SMP
// More than 8 threads are unlikely to provide a noticeable gain

View File

@@ -1131,13 +1131,13 @@ internal sealed class RarVM : BitInput
{
VMStandardFilterSignature[] stdList =
{
new VMStandardFilterSignature(53, 0xad576887, VMStandardFilters.VMSF_E8),
new VMStandardFilterSignature(57, 0x3cd7e57e, VMStandardFilters.VMSF_E8E9),
new VMStandardFilterSignature(120, 0x3769893f, VMStandardFilters.VMSF_ITANIUM),
new VMStandardFilterSignature(29, 0x0e06077d, VMStandardFilters.VMSF_DELTA),
new VMStandardFilterSignature(149, 0x1c2c5dc8, VMStandardFilters.VMSF_RGB),
new VMStandardFilterSignature(216, 0xbc85e701, VMStandardFilters.VMSF_AUDIO),
new VMStandardFilterSignature(40, 0x46b9c560, VMStandardFilters.VMSF_UPCASE)
new(53, 0xad576887, VMStandardFilters.VMSF_E8),
new(57, 0x3cd7e57e, VMStandardFilters.VMSF_E8E9),
new(120, 0x3769893f, VMStandardFilters.VMSF_ITANIUM),
new(29, 0x0e06077d, VMStandardFilters.VMSF_DELTA),
new(149, 0x1c2c5dc8, VMStandardFilters.VMSF_RGB),
new(216, 0xbc85e701, VMStandardFilters.VMSF_AUDIO),
new(40, 0x46b9c560, VMStandardFilters.VMSF_UPCASE)
};
var CodeCRC = RarCRC.CheckCrc(0xffffffff, code, 0, code.Length) ^ 0xffffffff;
for (var i = 0; i < stdList.Length; i++)

View File

@@ -4,13 +4,13 @@ namespace SharpCompress.Compressors.Rar.VM;
internal class VMPreparedProgram
{
internal List<VMPreparedCommand> Commands = new List<VMPreparedCommand>();
internal List<VMPreparedCommand> AltCommands = new List<VMPreparedCommand>();
internal List<VMPreparedCommand> Commands = new();
internal List<VMPreparedCommand> AltCommands = new();
public int CommandCount { get; set; }
internal List<byte> GlobalData = new List<byte>();
internal List<byte> StaticData = new List<byte>();
internal List<byte> GlobalData = new();
internal List<byte> StaticData = new();
// static data contained in DB operators
internal int[] InitR = new int[7];

View File

@@ -14,7 +14,7 @@ public sealed class XZBlock : XZReadOnlyStream
public int BlockHeaderSize => (_blockHeaderSizeByte + 1) * 4;
public ulong? CompressedSize { get; private set; }
public ulong? UncompressedSize { get; private set; }
public Stack<BlockFilter> Filters { get; private set; } = new Stack<BlockFilter>();
public Stack<BlockFilter> Filters { get; private set; } = new();
public bool HeaderIsLoaded { get; private set; }
private CheckType _checkType;
private readonly int _checkSize;

View File

@@ -13,7 +13,7 @@ public class XZIndex
private readonly BinaryReader _reader;
public long StreamStartPosition { get; private set; }
public ulong NumberOfRecords { get; private set; }
public List<XZIndexRecord> Records { get; } = new List<XZIndexRecord>();
public List<XZIndexRecord> Records { get; } = new();
private readonly bool _indexMarkerAlreadyVerified;

View File

@@ -19,7 +19,7 @@ public abstract class Factory : IFactory
RegisterFactory(new TarFactory());
}
private static readonly HashSet<Factory> _factories = new HashSet<Factory>();
private static readonly HashSet<Factory> _factories = new();
/// <summary>
/// Gets the collection of registered <see cref="IFactory"/>.

View File

@@ -3,22 +3,13 @@ using System.IO;
namespace SharpCompress.IO;
internal class BufferedSubStream : NonDisposingStream
internal class BufferedSubStream(Stream stream, long origin, long bytesToRead) : NonDisposingStream(stream, throwOnDispose: false)
{
private long position;
private int cacheOffset;
private int cacheLength;
private readonly byte[] cache;
private int _cacheOffset;
private int _cacheLength;
private readonly byte[] _cache = new byte[32 << 10];
public BufferedSubStream(Stream stream, long origin, long bytesToRead)
: base(stream, throwOnDispose: false)
{
position = origin;
BytesLeftToRead = bytesToRead;
cache = new byte[32 << 10];
}
private long BytesLeftToRead { get; set; }
private long BytesLeftToRead { get; set; } = bytesToRead;
public override bool CanRead => true;
@@ -45,22 +36,22 @@ internal class BufferedSubStream : NonDisposingStream
if (count > 0)
{
if (cacheLength == 0)
if (_cacheLength == 0)
{
cacheOffset = 0;
Stream.Position = position;
cacheLength = Stream.Read(cache, 0, cache.Length);
position += cacheLength;
_cacheOffset = 0;
Stream.Position = origin;
_cacheLength = Stream.Read(_cache, 0, _cache.Length);
origin += _cacheLength;
}
if (count > cacheLength)
if (count > _cacheLength)
{
count = cacheLength;
count = _cacheLength;
}
Buffer.BlockCopy(cache, cacheOffset, buffer, offset, count);
cacheOffset += count;
cacheLength -= count;
Buffer.BlockCopy(_cache, _cacheOffset, buffer, offset, count);
_cacheOffset += count;
_cacheLength -= count;
BytesLeftToRead -= count;
}

View File

@@ -8,18 +8,18 @@ public class DataDescriptorStream : Stream
{
private readonly Stream _stream;
private long _start;
private int _search_position;
private int _searchPosition;
private bool _isDisposed;
private bool _done;
private static byte[] DataDescriptorMarker = new byte[] { 0x50, 0x4b, 0x07, 0x08 };
private static long DataDescriptorSize = 24;
private static byte[] _dataDescriptorMarker = new byte[] { 0x50, 0x4b, 0x07, 0x08 };
private static long _dataDescriptorSize = 24;
public DataDescriptorStream(Stream stream)
{
_stream = stream;
_start = _stream.Position;
_search_position = 0;
_searchPosition = 0;
_done = false;
}
@@ -60,20 +60,20 @@ public class DataDescriptorStream : Stream
var br = new BinaryReader(stream);
br.ReadUInt32();
br.ReadUInt32(); // CRC32 can be checked if we calculate it
var compressed_size = br.ReadUInt32();
var uncompressed_size = br.ReadUInt32();
var uncompressed_64bit = br.ReadInt64();
var compressedSize = br.ReadUInt32();
var uncompressedSize = br.ReadUInt32();
var uncompressed64Bit = br.ReadInt64();
stream.Position -= DataDescriptorSize;
stream.Position -= _dataDescriptorSize;
var test_64bit = ((long)uncompressed_size << 32) | compressed_size;
var test64Bit = ((long)uncompressedSize << 32) | compressedSize;
if (test_64bit == size && test_64bit == uncompressed_64bit)
if (test64Bit == size && test64Bit == uncompressed64Bit)
{
return true;
}
if (compressed_size == size && compressed_size == uncompressed_size)
if (compressedSize == size && compressedSize == uncompressedSize)
{
return true;
}
@@ -92,20 +92,20 @@ public class DataDescriptorStream : Stream
for (var i = 0; i < read; i++)
{
if (buffer[offset + i] == DataDescriptorMarker[_search_position])
if (buffer[offset + i] == _dataDescriptorMarker[_searchPosition])
{
_search_position++;
_searchPosition++;
if (_search_position == 4)
if (_searchPosition == 4)
{
_search_position = 0;
_searchPosition = 0;
if (read - i > DataDescriptorSize)
if (read - i > _dataDescriptorSize)
{
var check = new MemoryStream(
buffer,
offset + i - 3,
(int)DataDescriptorSize
(int)_dataDescriptorSize
);
_done = validate_data_descriptor(
check,
@@ -131,15 +131,15 @@ public class DataDescriptorStream : Stream
}
else
{
_search_position = 0;
_searchPosition = 0;
}
}
if (_search_position > 0)
if (_searchPosition > 0)
{
read -= _search_position;
_stream.Position -= _search_position;
_search_position = 0;
read -= _searchPosition;
_stream.Position -= _searchPosition;
_searchPosition = 0;
}
return read;

View File

@@ -5,13 +5,13 @@ namespace SharpCompress.IO;
internal class ListeningStream : Stream
{
private long currentEntryTotalReadBytes;
private readonly IExtractionListener listener;
private long _currentEntryTotalReadBytes;
private readonly IExtractionListener _listener;
public ListeningStream(IExtractionListener listener, Stream stream)
{
Stream = stream;
this.listener = listener;
this._listener = listener;
}
protected override void Dispose(bool disposing)
@@ -44,8 +44,8 @@ internal class ListeningStream : Stream
public override int Read(byte[] buffer, int offset, int count)
{
var read = Stream.Read(buffer, offset, count);
currentEntryTotalReadBytes += read;
listener.FireCompressedBytesRead(currentEntryTotalReadBytes, currentEntryTotalReadBytes);
_currentEntryTotalReadBytes += read;
_listener.FireCompressedBytesRead(_currentEntryTotalReadBytes, _currentEntryTotalReadBytes);
return read;
}
@@ -57,8 +57,8 @@ internal class ListeningStream : Stream
return -1;
}
++currentEntryTotalReadBytes;
listener.FireCompressedBytesRead(currentEntryTotalReadBytes, currentEntryTotalReadBytes);
++_currentEntryTotalReadBytes;
_listener.FireCompressedBytesRead(_currentEntryTotalReadBytes, _currentEntryTotalReadBytes);
return value;
}

View File

@@ -72,8 +72,8 @@ internal class ReadOnlySubStream : NonDisposingStream
#if !NETFRAMEWORK && !NETSTANDARD2_0
public override int Read(Span<byte> buffer)
{
var slice_len = BytesLeftToRead < buffer.Length ? BytesLeftToRead : buffer.Length;
var read = Stream.Read(buffer.Slice(0, (int)slice_len));
var sliceLen = BytesLeftToRead < buffer.Length ? BytesLeftToRead : buffer.Length;
var read = Stream.Read(buffer.Slice(0, (int)sliceLen));
if (read > 0)
{
BytesLeftToRead -= read;

View File

@@ -5,98 +5,98 @@ namespace SharpCompress.IO;
public class RewindableStream : Stream
{
private readonly Stream stream;
private MemoryStream bufferStream = new MemoryStream();
private bool isRewound;
private bool isDisposed;
private readonly Stream _stream;
private MemoryStream _bufferStream = new();
private bool _isRewound;
private bool _isDisposed;
public RewindableStream(Stream stream) => this.stream = stream;
public RewindableStream(Stream stream) => this._stream = stream;
internal bool IsRecording { get; private set; }
protected override void Dispose(bool disposing)
{
if (isDisposed)
if (_isDisposed)
{
return;
}
isDisposed = true;
_isDisposed = true;
base.Dispose(disposing);
if (disposing)
{
stream.Dispose();
_stream.Dispose();
}
}
public void Rewind(bool stopRecording)
{
isRewound = true;
_isRewound = true;
IsRecording = !stopRecording;
bufferStream.Position = 0;
_bufferStream.Position = 0;
}
public void Rewind(MemoryStream buffer)
{
if (bufferStream.Position >= buffer.Length)
if (_bufferStream.Position >= buffer.Length)
{
bufferStream.Position -= buffer.Length;
_bufferStream.Position -= buffer.Length;
}
else
{
bufferStream.TransferTo(buffer);
_bufferStream.TransferTo(buffer);
//create new memorystream to allow proper resizing as memorystream could be a user provided buffer
//https://github.com/adamhathcock/sharpcompress/issues/306
bufferStream = new MemoryStream();
_bufferStream = new MemoryStream();
buffer.Position = 0;
buffer.TransferTo(bufferStream);
bufferStream.Position = 0;
buffer.TransferTo(_bufferStream);
_bufferStream.Position = 0;
}
isRewound = true;
_isRewound = true;
}
public void StartRecording()
{
//if (isRewound && bufferStream.Position != 0)
// throw new System.NotImplementedException();
if (bufferStream.Position != 0)
if (_bufferStream.Position != 0)
{
var data = bufferStream.ToArray();
var position = bufferStream.Position;
bufferStream.SetLength(0);
bufferStream.Write(data, (int)position, data.Length - (int)position);
bufferStream.Position = 0;
var data = _bufferStream.ToArray();
var position = _bufferStream.Position;
_bufferStream.SetLength(0);
_bufferStream.Write(data, (int)position, data.Length - (int)position);
_bufferStream.Position = 0;
}
IsRecording = true;
}
public override bool CanRead => true;
public override bool CanSeek => stream.CanSeek;
public override bool CanSeek => _stream.CanSeek;
public override bool CanWrite => false;
public override void Flush() { }
public override long Length => stream.Length;
public override long Length => _stream.Length;
public override long Position
{
get => stream.Position + bufferStream.Position - bufferStream.Length;
get => _stream.Position + _bufferStream.Position - _bufferStream.Length;
set
{
if (!isRewound)
if (!_isRewound)
{
stream.Position = value;
_stream.Position = value;
}
else if (value < stream.Position - bufferStream.Length || value >= stream.Position)
else if (value < _stream.Position - _bufferStream.Length || value >= _stream.Position)
{
stream.Position = value;
isRewound = false;
bufferStream.SetLength(0);
_stream.Position = value;
_isRewound = false;
_bufferStream.SetLength(0);
}
else
{
bufferStream.Position = value - stream.Position + bufferStream.Length;
_bufferStream.Position = value - _stream.Position + _bufferStream.Length;
}
}
}
@@ -110,32 +110,32 @@ public class RewindableStream : Stream
return 0;
}
int read;
if (isRewound && bufferStream.Position != bufferStream.Length)
if (_isRewound && _bufferStream.Position != _bufferStream.Length)
{
// don't read more than left
var readCount = Math.Min(count, (int)(bufferStream.Length - bufferStream.Position));
read = bufferStream.Read(buffer, offset, readCount);
var readCount = Math.Min(count, (int)(_bufferStream.Length - _bufferStream.Position));
read = _bufferStream.Read(buffer, offset, readCount);
if (read < readCount)
{
var tempRead = stream.Read(buffer, offset + read, count - read);
var tempRead = _stream.Read(buffer, offset + read, count - read);
if (IsRecording)
{
bufferStream.Write(buffer, offset + read, tempRead);
_bufferStream.Write(buffer, offset + read, tempRead);
}
read += tempRead;
}
if (bufferStream.Position == bufferStream.Length && !IsRecording)
if (_bufferStream.Position == _bufferStream.Length && !IsRecording)
{
isRewound = false;
bufferStream.SetLength(0);
_isRewound = false;
_bufferStream.SetLength(0);
}
return read;
}
read = stream.Read(buffer, offset, count);
read = _stream.Read(buffer, offset, count);
if (IsRecording)
{
bufferStream.Write(buffer, offset, read);
_bufferStream.Write(buffer, offset, read);
}
return read;
}

View File

@@ -1,27 +0,0 @@
#nullable disable
using System;
namespace SharpCompress;
public class Lazy<T>
{
private readonly Func<T> _lazyFunc;
private bool _evaluated;
private T _value;
public Lazy(Func<T> lazyFunc) => _lazyFunc = lazyFunc;
public T Value
{
get
{
if (!_evaluated)
{
_value = _lazyFunc();
_evaluated = true;
}
return _value;
}
}
}

View File

@@ -8,7 +8,7 @@ namespace SharpCompress;
internal sealed class LazyReadOnlyCollection<T> : ICollection<T>
{
private readonly List<T> backing = new List<T>();
private readonly List<T> backing = new();
private readonly IEnumerator<T> source;
private bool fullyLoaded;

View File

@@ -191,7 +191,7 @@ public abstract class AbstractReader<TEntry, TVolume> : IReader, IReaderExtracti
/// Retains a reference to the entry stream, so we can check whether it completed later.
/// </summary>
protected EntryStream CreateEntryStream(Stream decompressed) =>
new EntryStream(this, decompressed);
new(this, decompressed);
protected virtual EntryStream GetEntryStream() =>
CreateEntryStream(Entry.Parts.First().GetCompressedStream());

View File

@@ -14,10 +14,8 @@ namespace SharpCompress.Readers.Rar;
public abstract class RarReader : AbstractReader<RarReaderEntry, RarVolume>
{
private RarVolume? volume;
internal Lazy<IRarUnpack> UnpackV2017 { get; } =
new Lazy<IRarUnpack>(() => new Compressors.Rar.UnpackV2017.Unpack());
internal Lazy<IRarUnpack> UnpackV1 { get; } =
new Lazy<IRarUnpack>(() => new Compressors.Rar.UnpackV1.Unpack());
internal Lazy<IRarUnpack> UnpackV2017 { get; } = new(() => new Compressors.Rar.UnpackV2017.Unpack());
internal Lazy<IRarUnpack> UnpackV1 { get; } = new(() => new Compressors.Rar.UnpackV1.Unpack());
internal RarReader(ReaderOptions options)
: base(options, ArchiveType.Rar) { }

View File

@@ -9,8 +9,7 @@ namespace SharpCompress;
[CLSCompliant(false)]
public static class Utility
{
public static ReadOnlyCollection<T> ToReadOnly<T>(this ICollection<T> items) =>
new ReadOnlyCollection<T>(items);
public static ReadOnlyCollection<T> ToReadOnly<T>(this ICollection<T> items) => new(items);
/// <summary>
/// Performs an unsigned bitwise right shift with the specified number

View File

@@ -9,5 +9,5 @@ public class WriterOptions : OptionsBase
public CompressionType CompressionType { get; set; }
public static implicit operator WriterOptions(CompressionType compressionType) =>
new WriterOptions(compressionType);
new(compressionType);
}

View File

@@ -19,7 +19,7 @@ public class ZipWriter : AbstractWriter
{
private readonly CompressionType compressionType;
private readonly CompressionLevel compressionLevel;
private readonly List<ZipCentralDirectoryEntry> entries = new List<ZipCentralDirectoryEntry>();
private readonly List<ZipCentralDirectoryEntry> entries = new();
private readonly string zipComment;
private long streamPosition;
private PpmdProperties? ppmdProps;
@@ -324,7 +324,7 @@ public class ZipWriter : AbstractWriter
internal class ZipWritingStream : Stream
{
private readonly CRC32 crc = new CRC32();
private readonly CRC32 crc = new();
private readonly ZipCentralDirectoryEntry entry;
private readonly Stream originalStream;
private readonly Stream writeStream;