diff --git a/build/Program.cs b/build/Program.cs index e134a2b04..307b6d7f8 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -43,7 +43,7 @@ void RemoveDirectory(string d) Target(Format, () => { Run("dotnet", "tool restore"); - Run("dotnet", "format"); + Run("dotnet", "format --check"); }); Target(Build, DependsOn(Format), @@ -59,7 +59,7 @@ IEnumerable GetFiles(string d) { return Glob.Files(".", d); } - if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && framework == "net461") + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && framework == "net461") { return; } diff --git a/src/SharpCompress/Archives/Rar/RarArchive.cs b/src/SharpCompress/Archives/Rar/RarArchive.cs index 0b191056d..c7b0934c9 100644 --- a/src/SharpCompress/Archives/Rar/RarArchive.cs +++ b/src/SharpCompress/Archives/Rar/RarArchive.cs @@ -10,7 +10,7 @@ namespace SharpCompress.Archives.Rar { - public class + public class RarArchive : AbstractArchive { internal Lazy UnpackV2017 { get; } = new Lazy(() => new SharpCompress.Compressors.Rar.UnpackV2017.Unpack()); diff --git a/src/SharpCompress/Common/ExtractionMethods.cs b/src/SharpCompress/Common/ExtractionMethods.cs index 8301bcebd..51ded9794 100644 --- a/src/SharpCompress/Common/ExtractionMethods.cs +++ b/src/SharpCompress/Common/ExtractionMethods.cs @@ -15,7 +15,7 @@ public static void WriteEntryToDirectory(IEntry entry, { string destinationFileName; string fullDestinationDirectoryPath = Path.GetFullPath(destinationDirectory); - + //check for trailing slash. if (fullDestinationDirectoryPath[fullDestinationDirectoryPath.Length - 1] != Path.DirectorySeparatorChar) { diff --git a/src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs b/src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs index b24f045ba..8f9fd879e 100644 --- a/src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs +++ b/src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs @@ -36,7 +36,7 @@ internal IEnumerable ReadSeekableHeader(Stream stream) // ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR should be before the EOCD stream.Seek(eocd_location - ZIP64_EOCD_LENGTH - 4, SeekOrigin.Begin); uint zip64_locator = reader.ReadUInt32(); - if( zip64_locator != ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR ) + if (zip64_locator != ZIP64_END_OF_CENTRAL_DIRECTORY_LOCATOR) { throw new ArchiveException("Failed to locate the Zip64 Directory Locator"); } @@ -86,11 +86,11 @@ internal IEnumerable ReadSeekableHeader(Stream stream) } } - private static bool IsMatch( byte[] haystack, int position, byte[] needle) + private static bool IsMatch(byte[] haystack, int position, byte[] needle) { - for( int i = 0; i < needle.Length; i++ ) + for (int i = 0; i < needle.Length; i++) { - if( haystack[ position + i ] != needle[ i ] ) + if (haystack[position + i] != needle[i]) { return false; } @@ -120,9 +120,9 @@ private static void SeekBackToHeader(Stream stream, BinaryReader reader) // don't exclude the minimum eocd region, otherwise you fail to locate the header in empty zip files var max_search_area = len; // - MINIMUM_EOCD_LENGTH; - for( int pos_from_end = 0; pos_from_end < max_search_area; ++pos_from_end) + for (int pos_from_end = 0; pos_from_end < max_search_area; ++pos_from_end) { - if( IsMatch(seek, pos_from_end, needle) ) + if (IsMatch(seek, pos_from_end, needle)) { stream.Seek(-pos_from_end, SeekOrigin.End); return; diff --git a/src/SharpCompress/Utility.cs b/src/SharpCompress/Utility.cs index 6972854d5..bae51f10a 100644 --- a/src/SharpCompress/Utility.cs +++ b/src/SharpCompress/Utility.cs @@ -280,7 +280,7 @@ private static byte[] GetTransferByteArray() { return ArrayPool.Shared.Rent(81920); } - + public static bool ReadFully(this Stream stream, byte[] buffer) { int total = 0; @@ -295,7 +295,7 @@ public static bool ReadFully(this Stream stream, byte[] buffer) } return (total >= buffer.Length); } - + public static bool ReadFully(this Stream stream, Span buffer) { int total = 0; diff --git a/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs b/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs index 6412ff750..af8d2cf64 100644 --- a/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs +++ b/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs @@ -592,7 +592,7 @@ public void Zip_LongComment_Read() { string zipPath = Path.Combine(TEST_ARCHIVES_PATH, "Zip.LongComment.zip"); - using(ZipArchive za = ZipArchive.Open(zipPath)) + using (ZipArchive za = ZipArchive.Open(zipPath)) { var count = za.Entries.Count; Assert.Equal(1, count); diff --git a/tests/SharpCompress.Test/Zip/ZipReaderTests.cs b/tests/SharpCompress.Test/Zip/ZipReaderTests.cs index 24fbe0024..3db81542a 100644 --- a/tests/SharpCompress.Test/Zip/ZipReaderTests.cs +++ b/tests/SharpCompress.Test/Zip/ZipReaderTests.cs @@ -268,16 +268,16 @@ public void Zip_Deflate_WinzipAES_Read() } VerifyFiles(); } - + [Fact] public void Zip_Deflate_ZipCrypto_Read() { int count = 0; using (Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "zipcrypto.zip"))) using (var reader = ZipReader.Open(stream, new ReaderOptions() - { - Password = "test" - })) + { + Password = "test" + })) { while (reader.MoveToNextEntry()) {