diff --git a/src/SharpCompress/Archives/AbstractWritableArchive.cs b/src/SharpCompress/Archives/AbstractWritableArchive.cs index ffc739ac9..67f822fd8 100644 --- a/src/SharpCompress/Archives/AbstractWritableArchive.cs +++ b/src/SharpCompress/Archives/AbstractWritableArchive.cs @@ -83,8 +83,8 @@ IArchiveEntry IWritableArchive.AddEntry(string key, Stream source, bool closeStr public TEntry AddEntry(string key, Stream source, bool closeStream, long size = 0, DateTime? modified = null) { - if (key.StartsWith('/') - || key.StartsWith('\\')) + if (key.StartsWith("/") + || key.StartsWith("\\")) { key = key.Substring(1); } @@ -103,7 +103,7 @@ private bool DoesKeyMatchExisting(string key) foreach (var path in Entries.Select(x => x.Key)) { var p = path.Replace('/', '\\'); - if (p.StartsWith('\\')) + if (p.StartsWith("\\")) { p = p.Substring(1); } diff --git a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs index c961fe52d..08f567ed8 100644 --- a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs +++ b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs @@ -196,7 +196,7 @@ private static void WriteStringBytes(ReadOnlySpan name, Span buffer, { name.CopyTo(buffer); int i = Math.Min(length, name.Length); - buffer.Slice(i, length - i).Fill(0); + buffer.Slice(i, length - i).Clear(); } private static void WriteStringBytes(string name, byte[] buffer, int offset, int length) diff --git a/src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs b/src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs index 6068d610a..241479d5e 100644 --- a/src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs +++ b/src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs @@ -18,7 +18,7 @@ internal bool IsDirectory { get { - if (Name.EndsWith('/')) + if (Name.EndsWith("/")) { return true; } @@ -26,7 +26,7 @@ internal bool IsDirectory //.NET Framework 4.5 : System.IO.Compression::CreateFromDirectory() probably writes backslashes to headers return CompressedSize == 0 && UncompressedSize == 0 - && Name.EndsWith('\\'); + && Name.EndsWith("\\"); } } diff --git a/src/SharpCompress/Compressors/Deflate/GZipStream.cs b/src/SharpCompress/Compressors/Deflate/GZipStream.cs index e5572576a..ce126bc5b 100644 --- a/src/SharpCompress/Compressors/Deflate/GZipStream.cs +++ b/src/SharpCompress/Compressors/Deflate/GZipStream.cs @@ -372,16 +372,16 @@ public string FileName { return; } - if (_fileName.Contains('/')) + if (_fileName.Contains("/")) { _fileName = _fileName.Replace('/', '\\'); } - if (_fileName.EndsWith('\\')) + if (_fileName.EndsWith("\\")) { throw new InvalidOperationException("Illegal filename"); } - if (FileName.Contains('\\')) + if (FileName.Contains("\\")) { // trim any leading path int length = _fileName.Length; diff --git a/src/SharpCompress/Compressors/PPMd/H/ModelPPM.cs b/src/SharpCompress/Compressors/PPMd/H/ModelPPM.cs index 001c69503..842502751 100644 --- a/src/SharpCompress/Compressors/PPMd/H/ModelPPM.cs +++ b/src/SharpCompress/Compressors/PPMd/H/ModelPPM.cs @@ -137,7 +137,7 @@ public ModelPpm() private void RestartModelRare() { - new Span(_charMask).Fill(0); + new Span(_charMask).Clear(); SubAlloc.InitSubAllocator(); _initRl = -(_maxOrder < 12 ? _maxOrder : 12) - 1; int addr = SubAlloc.AllocContext(); @@ -228,7 +228,7 @@ private void StartModelRare(int maxOrder) private void ClearMask() { _escCount = 1; - new Span(_charMask).Fill(0); + new Span(_charMask).Clear(); } internal bool DecodeInit(IRarUnpack unpackRead, int escChar) diff --git a/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs b/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs index 38a1ca2c0..5c4ca30db 100644 --- a/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs +++ b/src/SharpCompress/Compressors/PPMd/H/SubAllocator.cs @@ -360,7 +360,7 @@ public virtual void DecPText(int dPText) public virtual void InitSubAllocator() { int i, k; - new Span(_heap, _freeListPos, SizeOfFreeList()).Fill(0); + new Span(_heap, _freeListPos, SizeOfFreeList()).Clear(); _pText = _heapStart; diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs index ff522c4a1..4e1d74c77 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs @@ -729,13 +729,13 @@ private void UnpInitData(bool solid) if (!solid) { tablesRead = false; - new Span(oldDist).Fill(0); // memset(oldDist,0,sizeof(OldDist)); + new Span(oldDist).Clear(); // memset(oldDist,0,sizeof(OldDist)); oldDistPtr = 0; lastDist = 0; lastLength = 0; - new Span(unpOldTable).Fill(0); // memset(UnpOldTable,0,sizeof(UnpOldTable)); + new Span(unpOldTable).Clear(); // memset(UnpOldTable,0,sizeof(UnpOldTable)); unpPtr = 0; wrPtr = 0; @@ -837,7 +837,7 @@ private bool ReadTables() if ((bitField & 0x4000) == 0) { - new Span(unpOldTable).Fill(0); // memset(UnpOldTable,0,sizeof(UnpOldTable)); + new Span(unpOldTable).Clear(); // memset(UnpOldTable,0,sizeof(UnpOldTable)); } AddBits(2); @@ -1109,7 +1109,7 @@ private bool AddVMCode(int firstByte, List vmCode, int length) oldFilterLengths[FiltPos] = StackFilter.BlockLength; // memset(StackFilter->Prg.InitR,0,sizeof(StackFilter->Prg.InitR)); - new Span(StackFilter.Program.InitR).Fill(0); + new Span(StackFilter.Program.InitR).Clear(); StackFilter.Program.InitR[3] = RarVM.VM_GLOBALMEMADDR; // StackFilter->Prg.InitR[3]=VM_GLOBALMEMADDR; StackFilter.Program.InitR[4] = StackFilter.BlockLength; diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack15.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack15.cs index 52144c209..435a6fcae 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack15.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack15.cs @@ -652,9 +652,9 @@ private void initHuff() ChSetC[I] = ((~I + 1) & 0xff) << 8; } - new Span(NToPl).Fill(0); // memset(NToPl,0,sizeof(NToPl)); - new Span(NToPlB).Fill(0); // memset(NToPlB,0,sizeof(NToPlB)); - new Span(NToPlC).Fill(0); // memset(NToPlC,0,sizeof(NToPlC)); + new Span(NToPl).Clear(); // memset(NToPl,0,sizeof(NToPl)); + new Span(NToPlB).Clear(); // memset(NToPlB,0,sizeof(NToPlB)); + new Span(NToPlC).Clear(); // memset(NToPlC,0,sizeof(NToPlC)); corrHuff(ChSetB, NToPlB); } @@ -670,7 +670,7 @@ private void corrHuff(int[] CharSet, int[] NumToPlace) // & ~0xff) | I; } } - new Span(NumToPlace).Fill(0); // memset(NumToPlace,0,sizeof(NToPl)); + new Span(NumToPlace).Clear(); // memset(NumToPlace,0,sizeof(NToPl)); for (I = 6; I >= 0; I--) { NumToPlace[I] = (7 - I) * 32; diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack20.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack20.cs index 94440890e..ad022c6bf 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack20.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack20.cs @@ -263,7 +263,7 @@ private bool ReadTables20() if (0 == (BitField & 0x4000)) { // memset(UnpOldTable20,0,sizeof(UnpOldTable20)); - new Span(UnpOldTable20).Fill(0); + new Span(UnpOldTable20).Clear(); } AddBits(2); @@ -371,7 +371,7 @@ private void unpInitData20(bool Solid) AudV[3] = new AudioVariables(); // memset(UnpOldTable20,0,sizeof(UnpOldTable20)); - new Span(UnpOldTable20).Fill(0); + new Span(UnpOldTable20).Clear(); } } diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackUtility.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackUtility.cs index 11fa777df..9559e9b48 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackUtility.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/UnpackUtility.cs @@ -187,7 +187,7 @@ internal static void makeDecodeTables(byte[] lenTab, int offset, Decode.Decode d int i; long M, N; - new Span(dec.DecodeNum).Fill(0); // memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum)); + new Span(dec.DecodeNum).Clear(); // memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum)); for (i = 0; i < size; i++) { diff --git a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack15_cpp.cs b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack15_cpp.cs index 44f2f5acc..fbcb55f10 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack15_cpp.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack15_cpp.cs @@ -546,9 +546,9 @@ private void InitHuff() ChSetA[I]=(ushort)I; ChSetC[I]=(ushort)(((~I+1) & 0xff)<<8); } - new Span(NToPl).Fill(0); - new Span(NToPlB).Fill(0); - new Span(NToPlC).Fill(0); + new Span(NToPl).Clear(); + new Span(NToPlB).Clear(); + new Span(NToPlC).Clear(); CorrHuff(ChSetB,NToPlB); } @@ -558,7 +558,7 @@ private void CorrHuff(ushort[] CharSet,byte[] NumToPlace) for (I=7;I>=0;I--) for (J=0;J<32;J++) CharSet[J]=(ushort)((CharSet[J] & ~0xff) | I); - new Span(NumToPlace, 0, NToPl.Length).Fill(0); + new Span(NumToPlace, 0, NToPl.Length).Clear(); for (I=6;I>=0;I--) NumToPlace[I]=(byte)((7-I)*32); } diff --git a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack20_cpp.cs b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack20_cpp.cs index c1400d9a1..05972f18f 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack20_cpp.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack20_cpp.cs @@ -231,7 +231,7 @@ private bool ReadTables20() if ((BitField & 0x4000) != 0) { - new Span(UnpOldTable20).Fill(0); + new Span(UnpOldTable20).Clear(); } Inp.addbits(2); @@ -363,7 +363,7 @@ private void UnpInitData20(bool Solid) //memset(AudV,0,sizeof(AudV)); AudV = new AudioVariables[4]; - new Span(UnpOldTable20).Fill(0); + new Span(UnpOldTable20).Clear(); //memset(MD,0,sizeof(MD)); MD = new DecodeTable[4]; } diff --git a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack_cpp.cs b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack_cpp.cs index 1add29720..549ca5d90 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack_cpp.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV2017/Unpack.unpack_cpp.cs @@ -220,7 +220,7 @@ private void UnpInitData(bool Solid) { if (!Solid) { - new Span(OldDist).Fill(0); + new Span(OldDist).Clear(); OldDistPtr=0; LastDist=LastLength=0; // memset(Window,0,MaxWinSize); @@ -270,7 +270,7 @@ private void MakeDecodeTables(byte[] LengthTable, int offset, DecodeTable Dec,ui // Set the entire DecodeNum to zero. //memset(Dec->DecodeNum,0,Size*sizeof(*Dec->DecodeNum)); - new Span(Dec.DecodeNum).Fill(0); + new Span(Dec.DecodeNum).Clear(); // Initialize not really used entry for zero length code. Dec.DecodePos[0]=0; diff --git a/src/SharpCompress/Crypto/RijndaelEngine.cs b/src/SharpCompress/Crypto/RijndaelEngine.cs index cb105d513..654d45567 100644 --- a/src/SharpCompress/Crypto/RijndaelEngine.cs +++ b/src/SharpCompress/Crypto/RijndaelEngine.cs @@ -81,7 +81,7 @@ public class RijndaelEngine 57, 75, 221, 124, 132, 151, 162, 253, 28, 36, 108, 180, 199, 82, 246, 1 }; - private static ReadOnlySpan S => new byte[] + private static readonly byte[] S = { 99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, @@ -101,7 +101,7 @@ public class RijndaelEngine 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22 }; - private static ReadOnlySpan Si => new byte[] + private static readonly byte[] Si = { 82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203,