diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 3cf567c5..9e8f2784 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "csharpier": { - "version": "0.26.1", + "version": "0.26.7", "commands": [ "dotnet-csharpier" ] diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 63da3a2e..27d73e23 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -17,16 +17,9 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-dotnet@v4 with: - dotnet-version: 7.0.x - - name: NuGet Caching - uses: actions/cache@v3 - with: - path: ~/.nuget/packages - key: ${{ runner.os }}-nuget-${{ hashFiles('packages.lock.json', '*/packages.lock.json') }} - restore-keys: | - ${{ runner.os }}-nuget- + dotnet-version: 8.0.x - run: dotnet run --project build/build.csproj - - uses: actions/upload-artifact@v3 + - uses: actions/upload-artifact@v4 with: name: ${{ matrix.os }}-sharpcompress.nupkg path: artifacts/* diff --git a/build/Program.cs b/build/Program.cs index 9475a66b..acafec41 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -61,7 +61,7 @@ void RemoveDirectory(string d) Target( Test, DependsOn(Build), - ForEach("net7.0", "net462"), + ForEach("net8.0", "net462"), framework => { IEnumerable GetFiles(string d) diff --git a/global.json b/global.json index e6e67e4e..391ba3c2 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.101", + "version": "8.0.100", "rollForward": "latestFeature" } } diff --git a/src/SharpCompress/Archives/ArchiveFactory.cs b/src/SharpCompress/Archives/ArchiveFactory.cs index 2e859599..3f479327 100644 --- a/src/SharpCompress/Archives/ArchiveFactory.cs +++ b/src/SharpCompress/Archives/ArchiveFactory.cs @@ -26,8 +26,7 @@ public static IArchive Open(Stream stream, ReaderOptions? readerOptions = null) public static IWritableArchive Create(ArchiveType type) { var factory = Factory - .Factories - .OfType() + .Factories.OfType() .FirstOrDefault(item => item.KnownArchiveType == type); if (factory != null) diff --git a/src/SharpCompress/Archives/Rar/RarArchive.cs b/src/SharpCompress/Archives/Rar/RarArchive.cs index e9c580fe..29d733f6 100644 --- a/src/SharpCompress/Archives/Rar/RarArchive.cs +++ b/src/SharpCompress/Archives/Rar/RarArchive.cs @@ -40,9 +40,9 @@ protected override IEnumerable LoadVolumes(SourceStream srcStream) streams[1].Position = 0; SrcStream.Position = 0; - return srcStream - .Streams - .Select(a => new StreamRarArchiveVolume(a, ReaderOptions, idx++)); + return srcStream.Streams.Select( + a => new StreamRarArchiveVolume(a, ReaderOptions, idx++) + ); } else //split mode or single file { diff --git a/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs b/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs index 99fe962d..7577b43d 100644 --- a/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs +++ b/src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs @@ -236,13 +236,11 @@ var group in entries.Where(x => !x.IsDirectory).GroupBy(x => x.FilePart.Folder) } else { - currentStream = archive - .database - .GetFolderStream( - stream, - currentFolder, - new PasswordProvider(Options.Password) - ); + currentStream = archive.database.GetFolderStream( + stream, + currentFolder, + new PasswordProvider(Options.Password) + ); } foreach (var entry in group) { diff --git a/src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs b/src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs index 251b919e..0b692035 100644 --- a/src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs +++ b/src/SharpCompress/Common/Zip/WinzipAesEncryptionData.cs @@ -48,15 +48,15 @@ internal static int KeyLengthInBytes(WinzipAesKeySize keySize) => private void Initialize() { -#if NET7_0 +#if NETFRAMEWORK || NETSTANDARD2_0 + var rfc2898 = new Rfc2898DeriveBytes(_password, _salt, RFC2898_ITERATIONS); +#else var rfc2898 = new Rfc2898DeriveBytes( _password, _salt, RFC2898_ITERATIONS, HashAlgorithmName.SHA1 ); -#else - var rfc2898 = new Rfc2898DeriveBytes(_password, _salt, RFC2898_ITERATIONS); #endif KeyBytes = rfc2898.GetBytes(KeySizeInBytes); // 16 or 24 or 32 ??? diff --git a/src/SharpCompress/Common/Zip/ZipHeaderFactory.cs b/src/SharpCompress/Common/Zip/ZipHeaderFactory.cs index bb03abac..8a58e220 100644 --- a/src/SharpCompress/Common/Zip/ZipHeaderFactory.cs +++ b/src/SharpCompress/Common/Zip/ZipHeaderFactory.cs @@ -142,9 +142,9 @@ private void LoadHeader(ZipFileEntry entryHeader, Stream stream) if (entryHeader.CompressionMethod == ZipCompressionMethod.WinzipAes) { - var data = entryHeader - .Extra - .SingleOrDefault(x => x.Type == ExtraDataType.WinZipAes); + var data = entryHeader.Extra.SingleOrDefault( + x => x.Type == ExtraDataType.WinZipAes + ); if (data != null) { var keySize = (WinzipAesKeySize)data.DataBytes[4]; diff --git a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs index 728d0f85..2ca62d6b 100644 --- a/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs +++ b/src/SharpCompress/Compressors/Rar/UnpackV1/Unpack.cs @@ -1269,10 +1269,9 @@ private bool AddVMCode(int firstByte, List vmCode, int length) if (CurSize < DataSize + RarVM.VM_FIXEDGLOBALSIZE) { // StackFilter->Prg.GlobalData.Add(DataSize+VM_FIXEDGLOBALSIZE-CurSize); - StackFilter - .Program - .GlobalData - .SetSize(DataSize + RarVM.VM_FIXEDGLOBALSIZE - CurSize); + StackFilter.Program.GlobalData.SetSize( + DataSize + RarVM.VM_FIXEDGLOBALSIZE - CurSize + ); } var offset = RarVM.VM_FIXEDGLOBALSIZE; globalData = StackFilter.Program.GlobalData; diff --git a/src/SharpCompress/SharpCompress.csproj b/src/SharpCompress/SharpCompress.csproj index 2c38668c..d3719849 100644 --- a/src/SharpCompress/SharpCompress.csproj +++ b/src/SharpCompress/SharpCompress.csproj @@ -6,7 +6,7 @@ 0.34.2 0.34.2 Adam Hathcock - net462;netstandard2.0;netstandard2.1;net6.0;net7.0 + net462;netstandard2.0;netstandard2.1;net6.0;net7.0;net8.0 SharpCompress ../../SharpCompress.snk true @@ -27,18 +27,18 @@ - - + + - + - + - + diff --git a/src/SharpCompress/Writers/WriterFactory.cs b/src/SharpCompress/Writers/WriterFactory.cs index 1f14f6bb..50e1fdfc 100644 --- a/src/SharpCompress/Writers/WriterFactory.cs +++ b/src/SharpCompress/Writers/WriterFactory.cs @@ -10,9 +10,7 @@ public static class WriterFactory public static IWriter Open(Stream stream, ArchiveType archiveType, WriterOptions writerOptions) { var factory = Factories - .Factory - .Factories - .OfType() + .Factory.Factories.OfType() .FirstOrDefault(item => item.KnownArchiveType == archiveType); if (factory != null) diff --git a/tests/SharpCompress.Test/SharpCompress.Test.csproj b/tests/SharpCompress.Test/SharpCompress.Test.csproj index c20664a7..e1f75276 100644 --- a/tests/SharpCompress.Test/SharpCompress.Test.csproj +++ b/tests/SharpCompress.Test/SharpCompress.Test.csproj @@ -1,6 +1,6 @@  - net7.0;net462 + net8.0;net462 SharpCompress.Test SharpCompress.Test @@ -8,13 +8,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/tests/SharpCompress.Test/Tar/TarArchiveTests.cs b/tests/SharpCompress.Test/Tar/TarArchiveTests.cs index 711b14c1..490698b2 100644 --- a/tests/SharpCompress.Test/Tar/TarArchiveTests.cs +++ b/tests/SharpCompress.Test/Tar/TarArchiveTests.cs @@ -198,9 +198,9 @@ public void Tar_Random_Write_Remove() using (var archive = TarArchive.Open(unmodified)) { - var entry = archive - .Entries - .Single(x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)); + var entry = archive.Entries.Single( + x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) + ); archive.RemoveEntry(entry); archive.SaveTo(scratchPath, CompressionType.None); } diff --git a/tests/SharpCompress.Test/Tar/TarReaderTests.cs b/tests/SharpCompress.Test/Tar/TarReaderTests.cs index 4952b702..e3a27296 100644 --- a/tests/SharpCompress.Test/Tar/TarReaderTests.cs +++ b/tests/SharpCompress.Test/Tar/TarReaderTests.cs @@ -209,11 +209,9 @@ public void Tar_Broken_Stream() [Fact] public void Tar_GZip_With_Symlink_Entries() { - var isWindows = System - .Runtime - .InteropServices - .RuntimeInformation - .IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows); + var isWindows = System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform( + System.Runtime.InteropServices.OSPlatform.Windows + ); using ( Stream stream = File.OpenRead(Path.Combine(TEST_ARCHIVES_PATH, "TarWithSymlink.tar.gz")) ) @@ -256,15 +254,12 @@ public void Tar_GZip_With_Symlink_Entries() { // need to convert the link to an absolute path for comparison var target = reader.Entry.LinkTarget; - var realTarget = System - .IO - .Path - .GetFullPath( - System - .IO - .Path - .Combine($"{System.IO.Path.GetDirectoryName(path)}", target) - ); + var realTarget = System.IO.Path.GetFullPath( + System.IO.Path.Combine( + $"{System.IO.Path.GetDirectoryName(path)}", + target + ) + ); Assert.Equal(realTarget, link.GetContents().ToString()); } diff --git a/tests/SharpCompress.Test/TestBase.cs b/tests/SharpCompress.Test/TestBase.cs index b4966c31..3ad1fe79 100644 --- a/tests/SharpCompress.Test/TestBase.cs +++ b/tests/SharpCompress.Test/TestBase.cs @@ -20,10 +20,10 @@ public class TestBase : IDisposable public TestBase() { - var index = AppDomain - .CurrentDomain - .BaseDirectory - .IndexOf("SharpCompress.Test", StringComparison.OrdinalIgnoreCase); + var index = AppDomain.CurrentDomain.BaseDirectory.IndexOf( + "SharpCompress.Test", + StringComparison.OrdinalIgnoreCase + ); var path = AppDomain.CurrentDomain.BaseDirectory.Substring(0, index); SOLUTION_BASE_PATH = Path.GetDirectoryName(path) ?? throw new ArgumentNullException(); diff --git a/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs b/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs index 080ae318..fde87dc6 100644 --- a/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs +++ b/tests/SharpCompress.Test/Zip/ZipArchiveTests.cs @@ -184,9 +184,9 @@ public void Zip_Random_Write_Remove() using (var archive = ZipArchive.Open(unmodified)) { - var entry = archive - .Entries - .Single(x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)); + var entry = archive.Entries.Single( + x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) + ); archive.RemoveEntry(entry); WriterOptions writerOptions = new ZipWriterOptions(CompressionType.Deflate); @@ -252,9 +252,9 @@ public void Zip_Removal_Poly() ) ); Assert.Null( - ((IArchive)vfs) - .Entries - .FirstOrDefault(v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)) + ((IArchive)vfs).Entries.FirstOrDefault( + v => v.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) + ) ); } } @@ -391,14 +391,14 @@ var file in Directory.EnumerateFiles( { archive.AddAllFromDirectory(SCRATCH_FILES_PATH); archive.RemoveEntry( - archive - .Entries - .Single(x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)) + archive.Entries.Single( + x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) + ) ); Assert.Null( - archive - .Entries - .FirstOrDefault(x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase)) + archive.Entries.FirstOrDefault( + x => x.Key.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) + ) ); } Directory.Delete(SCRATCH_FILES_PATH, true);