From f533b6321ea910c3bcf02768191c0e8e21294012 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 16 Feb 2026 11:20:28 +0000 Subject: [PATCH] last style changes for now --- .editorconfig | 6 +++--- src/SharpCompress/Common/EntryStream.cs | 2 ++ .../Common/Tar/TarReadOnlySubStream.cs | 2 ++ .../Common/Zip/WinzipAesCryptoStream.cs | 2 ++ .../Writers/Zip/ZipWriterEntryOptions.cs | 20 ------------------- .../SharpCompress.Test/Zip/Zip64AsyncTests.cs | 2 +- tests/SharpCompress.Test/Zip/Zip64Tests.cs | 2 +- 7 files changed, 11 insertions(+), 25 deletions(-) diff --git a/.editorconfig b/.editorconfig index e06cce0b..e94ae1dd 100644 --- a/.editorconfig +++ b/.editorconfig @@ -270,7 +270,7 @@ dotnet_diagnostic.CA1307.severity = error # specify StringComparison for clarity dotnet_diagnostic.CA1309.severity = error # use ordinal StringComparison dotnet_diagnostic.CA1310.severity = error # specify StringComparison for correctness dotnet_diagnostic.CA1507.severity = error # use nameof in place of string literals -dotnet_diagnostic.CA1513.severity = error # use ObjectDisposedException throw helper +dotnet_diagnostic.CA1513.severity = suggestion # use ObjectDisposedException throw helper dotnet_diagnostic.CA1707.severity = suggestion # identifiers should not contain underscores dotnet_diagnostic.CA1708.severity = suggestion # identifiers should differ by more than case dotnet_diagnostic.CA1711.severity = suggestion # identifiers should not have incorrect suffixes @@ -309,7 +309,7 @@ dotnet_diagnostic.CA1712.severity = suggestion # do not prefix enum values with dotnet_diagnostic.CA2022.severity = suggestion # avoid inexact reads with Stream.Read dotnet_diagnostic.CA1850.severity = error # prefer static HashData over ComputeHash dotnet_diagnostic.CA2263.severity = error # prefer generic overload when type is known -dotnet_diagnostic.CA2012.severity = suggestion # use ValueTasks correctly +dotnet_diagnostic.CA2012.severity = error # use ValueTasks correctly dotnet_diagnostic.CA1001.severity = error # disposable field owners should be disposable dotnet_diagnostic.CS0169.severity = error # field is never used @@ -319,7 +319,7 @@ dotnet_diagnostic.CS1998.severity = error # async method lacks await operators dotnet_diagnostic.CS8602.severity = error # possible null reference dereference dotnet_diagnostic.CS8604.severity = error # possible null reference argument dotnet_diagnostic.CS8618.severity = error # non-nullable member is uninitialized -dotnet_diagnostic.CS0618.severity = suggestion # obsolete member usage +dotnet_diagnostic.CS0618.severity = error # obsolete member usage dotnet_diagnostic.CS4014.severity = error # unawaited task call dotnet_diagnostic.CS8600.severity = error # possible null to non-nullable conversion dotnet_diagnostic.CS8603.severity = error # possible null reference return diff --git a/src/SharpCompress/Common/EntryStream.cs b/src/SharpCompress/Common/EntryStream.cs index 144f77c7..b8ccf339 100644 --- a/src/SharpCompress/Common/EntryStream.cs +++ b/src/SharpCompress/Common/EntryStream.cs @@ -42,7 +42,9 @@ public partial class EntryStream : Stream if (Utility.UseSyncOverAsyncDispose()) { #pragma warning disable VSTHRD002 // Avoid problematic synchronous waits +#pragma warning disable CA2012 SkipEntryAsync().GetAwaiter().GetResult(); +#pragma warning restore CA2012 #pragma warning restore VSTHRD002 // Avoid problematic synchronous waits } else diff --git a/src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs b/src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs index 6f9c46fa..987751a3 100644 --- a/src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs +++ b/src/SharpCompress/Common/Tar/TarReadOnlySubStream.cs @@ -39,7 +39,9 @@ internal class TarReadOnlySubStream : Stream if (Utility.UseSyncOverAsyncDispose()) { #pragma warning disable VSTHRD002 // Avoid problematic synchronous waits +#pragma warning disable CA2012 _stream.SkipAsync(512 - bytesInLastBlock).GetAwaiter().GetResult(); +#pragma warning restore CA2012 #pragma warning restore VSTHRD002 // Avoid problematic synchronous waits } else diff --git a/src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs b/src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs index bc8c1b2e..bb7cff31 100644 --- a/src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs +++ b/src/SharpCompress/Common/Zip/WinzipAesCryptoStream.cs @@ -76,7 +76,9 @@ internal partial class WinzipAesCryptoStream : Stream try { #pragma warning disable VSTHRD002 // Avoid problematic synchronous waits +#pragma warning disable CA2012 _stream.ReadFullyAsync(ten, 0, 10).GetAwaiter().GetResult(); +#pragma warning restore CA2012 #pragma warning restore VSTHRD002 // Avoid problematic synchronous waits } finally diff --git a/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs b/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs index d51f2bd1..ef601c21 100644 --- a/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs +++ b/src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs @@ -44,26 +44,6 @@ public class ZipWriterEntryOptions } } - /// - /// When CompressionType.Deflate is used, this property is referenced. - /// Valid range: 0-9 (0=no compression, 6=default, 9=best compression). - /// When null, uses the archive's default compression level. - /// - /// - /// This property is deprecated. Use instead. - /// - [Obsolete( - "Use CompressionLevel property instead. This property will be removed in a future version." - )] - public CompressionLevel? DeflateCompressionLevel - { - get => - CompressionLevel.HasValue - ? (CompressionLevel)Math.Min(CompressionLevel.Value, 9) - : null; - set => CompressionLevel = value.HasValue ? (int)value.Value : null; - } - public string? EntryComment { get; set; } public DateTime? ModificationDateTime { get; set; } diff --git a/tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs b/tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs index 48b29ff4..2d7a0c7b 100644 --- a/tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs +++ b/tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs @@ -173,7 +173,7 @@ public class Zip64AsyncTests : WriterTests var opts = new ZipWriterOptions(CompressionType.Deflate) { UseZip64 = setZip64 }; // Use no compression to ensure we hit the limits (actually inflates a bit, but seems better than using method==Store) - var eo = new ZipWriterEntryOptions { DeflateCompressionLevel = CompressionLevel.None }; + var eo = new ZipWriterEntryOptions { CompressionLevel = 0 }; using var zip = File.OpenWrite(filename); using var st = forwardOnly ? (Stream)new ForwardOnlyStream(zip) : zip; diff --git a/tests/SharpCompress.Test/Zip/Zip64Tests.cs b/tests/SharpCompress.Test/Zip/Zip64Tests.cs index 6242b877..68d27625 100644 --- a/tests/SharpCompress.Test/Zip/Zip64Tests.cs +++ b/tests/SharpCompress.Test/Zip/Zip64Tests.cs @@ -158,7 +158,7 @@ public class Zip64Tests : WriterTests var opts = new ZipWriterOptions(CompressionType.Deflate) { UseZip64 = setZip64 }; // Use no compression to ensure we hit the limits (actually inflates a bit, but seems better than using method==Store) - var eo = new ZipWriterEntryOptions { DeflateCompressionLevel = CompressionLevel.None }; + var eo = new ZipWriterEntryOptions { CompressionLevel = 0 }; using var zip = File.OpenWrite(filename); using var st = forwardOnly ? (Stream)new ForwardOnlyStream(zip) : zip;