From 7f286da74e263d94a1469dca81c430f4cb9cbbcf Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 16 Feb 2026 11:15:58 +0000 Subject: [PATCH] more build fixes --- .editorconfig | 8 +-- build/Program.cs | 8 +-- .../Archives/ArchiveVolumeFactory.cs | 4 +- .../Archives/Rar/RarArchiveVolumeFactory.cs | 14 ++++- .../Archives/Zip/ZipArchiveVolumeFactory.cs | 4 +- .../Common/Arj/Headers/DosDateTime.cs | 2 +- src/SharpCompress/Common/Constants.cs | 4 ++ src/SharpCompress/Common/FlagUtility.cs | 13 ++++- src/SharpCompress/Common/Rar/RarEntry.cs | 1 + .../Common/Tar/Headers/TarHeader.cs | 2 +- .../Compressors/Arj/HuffmanTree.cs | 7 ++- .../Compressors/Deflate/DeflateManager.cs | 14 ++++- .../Compressors/Deflate/DeflateStream.cs | 1 + .../Compressors/Deflate/GZipStream.cs | 9 ++++ .../Compressors/Deflate/Inflate.cs | 10 +++- .../Compressors/Deflate/ZlibBaseStream.cs | 51 ++++++++++++++++--- .../Compressors/Deflate/ZlibCodec.cs | 1 + .../Compressors/Deflate/ZlibStream.cs | 1 + .../Compressors/Lzw/LzwStream.Async.cs | 2 + .../Compressors/Lzw/LzwStream.cs | 2 + src/SharpCompress/IO/MarkingBinaryReader.cs | 1 + src/SharpCompress/Writers/Tar/TarWriter.cs | 4 ++ src/SharpCompress/Writers/Zip/ZipWriter.cs | 4 ++ 23 files changed, 142 insertions(+), 25 deletions(-) diff --git a/.editorconfig b/.editorconfig index eaab4189..e06cce0b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -265,12 +265,12 @@ dotnet_diagnostic.CA1051.severity = suggestion # do not declare visible instance dotnet_diagnostic.CA1068.severity = error # cancellation token parameters must come last dotnet_diagnostic.CA1069.severity = error # enums should not have duplicate values dotnet_diagnostic.CA1304.severity = error # specify CultureInfo for culture-sensitive operations -dotnet_diagnostic.CA1305.severity = suggestion # specify IFormatProvider -dotnet_diagnostic.CA1307.severity = suggestion # specify StringComparison for clarity +dotnet_diagnostic.CA1305.severity = error # specify IFormatProvider +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 = suggestion # use ObjectDisposedException throw helper +dotnet_diagnostic.CA1513.severity = error # 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 @@ -405,6 +405,8 @@ dotnet_diagnostic.VSTHRD200.severity = none # use Async suffix naming convention [tests/**/*.cs] dotnet_diagnostic.CA1861.severity = suggestion # avoid constant arrays as arguments +dotnet_diagnostic.CA1305.severity = suggestion # specify IFormatProvider +dotnet_diagnostic.CA1307.severity = suggestion # specify StringComparison for clarity dotnet_diagnostic.IDE0042.severity = suggestion dotnet_diagnostic.IDE0051.severity = suggestion dotnet_diagnostic.IDE0063.severity = suggestion diff --git a/build/Program.cs b/build/Program.cs index f2072b7a..1c36e0a9 100644 --- a/build/Program.cs +++ b/build/Program.cs @@ -593,7 +593,7 @@ static Dictionary ParseBenchmarkResults(string markdown var parts = line.Split('|', StringSplitOptions.TrimEntries); if (parts.Length >= 5) { - var method = parts[1].Replace("'", "'"); + var method = parts[1].Replace("'", "'", StringComparison.Ordinal); var meanStr = parts[2]; // Find Allocated column - it's usually the last column or labeled "Allocated" @@ -604,7 +604,7 @@ static Dictionary ParseBenchmarkResults(string markdown parts[j].Contains("KB", StringComparison.Ordinal) || parts[j].Contains("MB", StringComparison.Ordinal) || parts[j].Contains("GB", StringComparison.Ordinal) - || parts[j].Contains('B') + || parts[j].Contains('B', StringComparison.Ordinal) ) { memoryStr = parts[j]; @@ -642,7 +642,7 @@ static double ParseTimeValue(string timeStr) } // Remove thousands separators and parse - timeStr = timeStr.Replace(",", "").Trim(); + timeStr = timeStr.Replace(",", "", StringComparison.Ordinal).Trim(); var match = Regex.Match(timeStr, @"([\d.]+)\s*(\w+)"); if (!match.Success) @@ -671,7 +671,7 @@ static double ParseMemoryValue(string memStr) return 0; } - memStr = memStr.Replace(",", "").Trim(); + memStr = memStr.Replace(",", "", StringComparison.Ordinal).Trim(); var match = Regex.Match(memStr, @"([\d.]+)\s*(\w+)"); if (!match.Success) diff --git a/src/SharpCompress/Archives/ArchiveVolumeFactory.cs b/src/SharpCompress/Archives/ArchiveVolumeFactory.cs index 26d7c640..9bf86ce2 100644 --- a/src/SharpCompress/Archives/ArchiveVolumeFactory.cs +++ b/src/SharpCompress/Archives/ArchiveVolumeFactory.cs @@ -19,7 +19,9 @@ internal abstract class ArchiveVolumeFactory part1.DirectoryName!, String.Concat( m.Groups[1].Value, - (index + 1).ToString().PadLeft(m.Groups[2].Value.Length, '0') + (index + 1) + .ToString(global::SharpCompress.Common.Constants.DefaultCultureInfo) + .PadLeft(m.Groups[2].Value.Length, '0') ) ) ); diff --git a/src/SharpCompress/Archives/Rar/RarArchiveVolumeFactory.cs b/src/SharpCompress/Archives/Rar/RarArchiveVolumeFactory.cs index 1bd98f58..33ad21a9 100644 --- a/src/SharpCompress/Archives/Rar/RarArchiveVolumeFactory.cs +++ b/src/SharpCompress/Archives/Rar/RarArchiveVolumeFactory.cs @@ -19,7 +19,9 @@ internal static class RarArchiveVolumeFactory part1.DirectoryName!, String.Concat( m.Groups[1].Value, - (index + 1).ToString().PadLeft(m.Groups[2].Value.Length, '0'), + (index + 1) + .ToString(global::SharpCompress.Common.Constants.DefaultCultureInfo) + .PadLeft(m.Groups[2].Value.Length, '0'), m.Groups[3].Value ) ) @@ -39,7 +41,15 @@ internal static class RarArchiveVolumeFactory index == 0 ? m.Groups[2].Value + m.Groups[3].Value : (char)(m.Groups[2].Value[0] + ((index - 1) / 100)) - + (index - 1).ToString("D4").Substring(2) + + (index - 1) + .ToString( + "D4", + global::SharpCompress + .Common + .Constants + .DefaultCultureInfo + ) + .Substring(2) ) ) ); diff --git a/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs b/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs index 0f0b6517..257c6db0 100644 --- a/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs +++ b/src/SharpCompress/Archives/Zip/ZipArchiveVolumeFactory.cs @@ -21,7 +21,9 @@ internal static class ZipArchiveVolumeFactory String.Concat( m.Groups[1].Value, Regex.Replace(m.Groups[2].Value, @"[^xz]", ""), - index.ToString().PadLeft(2, '0') + index + .ToString(global::SharpCompress.Common.Constants.DefaultCultureInfo) + .PadLeft(2, '0') ) ) ); diff --git a/src/SharpCompress/Common/Arj/Headers/DosDateTime.cs b/src/SharpCompress/Common/Arj/Headers/DosDateTime.cs index c882e212..606f51a7 100644 --- a/src/SharpCompress/Common/Arj/Headers/DosDateTime.cs +++ b/src/SharpCompress/Common/Arj/Headers/DosDateTime.cs @@ -32,5 +32,5 @@ public class DosDateTime } } - public override string ToString() => DateTime.ToString("yyyy-MM-dd HH:mm:ss"); + public override string ToString() => DateTime.ToString("yyyy-MM-dd HH:mm:ss", Constants.DefaultCultureInfo); } diff --git a/src/SharpCompress/Common/Constants.cs b/src/SharpCompress/Common/Constants.cs index b9ffcbe3..5fba5ed9 100644 --- a/src/SharpCompress/Common/Constants.cs +++ b/src/SharpCompress/Common/Constants.cs @@ -1,3 +1,5 @@ +using System.Globalization; + namespace SharpCompress.Common; public static class Constants @@ -38,4 +40,6 @@ public static class Constants /// /// public static int RewindableBufferSize { get; set; } = 81920; + + public static CultureInfo DefaultCultureInfo { get; set; } = CultureInfo.InvariantCulture; } diff --git a/src/SharpCompress/Common/FlagUtility.cs b/src/SharpCompress/Common/FlagUtility.cs index 8f272b9d..47b7f7ea 100644 --- a/src/SharpCompress/Common/FlagUtility.cs +++ b/src/SharpCompress/Common/FlagUtility.cs @@ -46,7 +46,11 @@ internal static class FlagUtility /// Flag to test /// public static bool HasFlag(T bitField, T flag) - where T : struct => HasFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag)); + where T : struct => + HasFlag( + Convert.ToInt64(bitField, Constants.DefaultCultureInfo), + Convert.ToInt64(flag, Constants.DefaultCultureInfo) + ); /// /// Returns true if the flag is set on the specified bit field. @@ -82,5 +86,10 @@ internal static class FlagUtility /// bool /// The flagged variable with the flag changed public static long SetFlag(T bitField, T flag, bool on) - where T : struct => SetFlag(Convert.ToInt64(bitField), Convert.ToInt64(flag), on); + where T : struct => + SetFlag( + Convert.ToInt64(bitField, Constants.DefaultCultureInfo), + Convert.ToInt64(flag, Constants.DefaultCultureInfo), + on + ); } diff --git a/src/SharpCompress/Common/Rar/RarEntry.cs b/src/SharpCompress/Common/Rar/RarEntry.cs index 9c0f7ae5..3393f06c 100644 --- a/src/SharpCompress/Common/Rar/RarEntry.cs +++ b/src/SharpCompress/Common/Rar/RarEntry.cs @@ -76,6 +76,7 @@ public abstract class RarEntry : Entry public override string ToString() => string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Entry Path: {0} Compressed Size: {1} Uncompressed Size: {2} CRC: {3}", Key, CompressedSize, diff --git a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs index 5ceda5e7..83018a3f 100644 --- a/src/SharpCompress/Common/Tar/Headers/TarHeader.cs +++ b/src/SharpCompress/Common/Tar/Headers/TarHeader.cs @@ -457,7 +457,7 @@ internal sealed partial class TarHeader { return 0; } - return Convert.ToInt64(s); + return Convert.ToInt64(s, Constants.DefaultCultureInfo); } private static readonly byte[] eightSpaces = diff --git a/src/SharpCompress/Compressors/Arj/HuffmanTree.cs b/src/SharpCompress/Compressors/Arj/HuffmanTree.cs index a7426ca2..2e4ddd57 100644 --- a/src/SharpCompress/Compressors/Arj/HuffmanTree.cs +++ b/src/SharpCompress/Compressors/Arj/HuffmanTree.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.IO; using System.Text; +using SharpCompress.Common; namespace SharpCompress.Compressors.Arj; @@ -189,7 +190,11 @@ public sealed partial class HuffTree var node = _tree[index]; if (node.Type == NodeType.Leaf) { - result.AppendLine($"{prefix} -> {node.LeafValue}"); + result + .Append(prefix) + .Append(" -> ") + .Append(node.LeafValue.ToString(Constants.DefaultCultureInfo)) + .AppendLine(); } else { diff --git a/src/SharpCompress/Compressors/Deflate/DeflateManager.cs b/src/SharpCompress/Compressors/Deflate/DeflateManager.cs index 933f5752..a7b643cb 100644 --- a/src/SharpCompress/Compressors/Deflate/DeflateManager.cs +++ b/src/SharpCompress/Compressors/Deflate/DeflateManager.cs @@ -1706,7 +1706,11 @@ internal sealed partial class DeflateManager if (memLevel < 1 || memLevel > MEM_LEVEL_MAX) { throw new ZlibException( - string.Format("memLevel must be in the range 1.. {0}", MEM_LEVEL_MAX) + string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "memLevel must be in the range 1.. {0}", + MEM_LEVEL_MAX + ) ); } @@ -1876,7 +1880,13 @@ internal sealed partial class DeflateManager _codec.Message = _ErrorMessage[ ZlibConstants.Z_NEED_DICT - (ZlibConstants.Z_STREAM_ERROR) ]; - throw new ZlibException(string.Format("Something is fishy. [{0}]", _codec.Message)); + throw new ZlibException( + string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "Something is fishy. [{0}]", + _codec.Message + ) + ); //return ZlibConstants.Z_STREAM_ERROR; } diff --git a/src/SharpCompress/Compressors/Deflate/DeflateStream.cs b/src/SharpCompress/Compressors/Deflate/DeflateStream.cs index d9249d1f..6e212db6 100644 --- a/src/SharpCompress/Compressors/Deflate/DeflateStream.cs +++ b/src/SharpCompress/Compressors/Deflate/DeflateStream.cs @@ -120,6 +120,7 @@ public partial class DeflateStream : Stream, IStreamStack { throw new ZlibException( string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Don't be silly. {0} bytes?? Use a bigger buffer, at least {1}.", value, ZlibConstants.WorkingBufferSizeMin diff --git a/src/SharpCompress/Compressors/Deflate/GZipStream.cs b/src/SharpCompress/Compressors/Deflate/GZipStream.cs index b0b13216..04c7a5d9 100644 --- a/src/SharpCompress/Compressors/Deflate/GZipStream.cs +++ b/src/SharpCompress/Compressors/Deflate/GZipStream.cs @@ -116,6 +116,7 @@ public partial class GZipStream : Stream { throw new ZlibException( string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Don't be silly. {0} bytes?? Use a bigger buffer, at least {1}.", value, ZlibConstants.WorkingBufferSizeMin @@ -402,7 +403,11 @@ public partial class GZipStream : Stream { return; } +#if LEGACY_DOTNET if (_fileName.Contains('/')) +#else + if (_fileName.Contains('/', StringComparison.Ordinal)) +#endif { _fileName = _fileName.Replace('/', '\\'); } @@ -411,7 +416,11 @@ public partial class GZipStream : Stream throw new InvalidOperationException("Illegal filename"); } +#if LEGACY_DOTNET if (_fileName.Contains('\\')) +#else + if (_fileName.Contains('\\', StringComparison.Ordinal)) +#endif { // trim any leading path _fileName = Path.GetFileName(_fileName); diff --git a/src/SharpCompress/Compressors/Deflate/Inflate.cs b/src/SharpCompress/Compressors/Deflate/Inflate.cs index aff2c659..664f1bf4 100644 --- a/src/SharpCompress/Compressors/Deflate/Inflate.cs +++ b/src/SharpCompress/Compressors/Deflate/Inflate.cs @@ -1746,6 +1746,7 @@ internal sealed class InflateManager { mode = InflateManagerMode.BAD; _codec.Message = string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "unknown compression method (0x{0:X2})", method ); @@ -1756,6 +1757,7 @@ internal sealed class InflateManager { mode = InflateManagerMode.BAD; _codec.Message = string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "invalid window size ({0})", (method >> 4) + 8 ); @@ -1945,7 +1947,13 @@ internal sealed class InflateManager return ZlibConstants.Z_STREAM_END; case InflateManagerMode.BAD: - throw new ZlibException(string.Format("Bad state ({0})", _codec.Message)); + throw new ZlibException( + string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "Bad state ({0})", + _codec.Message + ) + ); default: throw new ZlibException("Stream error."); diff --git a/src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs b/src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs index bd81d041..46778000 100644 --- a/src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs +++ b/src/SharpCompress/Compressors/Deflate/ZlibBaseStream.cs @@ -275,7 +275,14 @@ internal class ZlibBaseStream : Stream, IStreamStack var verb = (_wantCompress ? "de" : "in") + "flating"; if (_z.Message is null) { - throw new ZlibException(String.Format("{0}: (rc = {1})", verb, rc)); + throw new ZlibException( + String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "{0}: (rc = {1})", + verb, + rc + ) + ); } throw new ZlibException(verb + ": " + _z.Message); } @@ -344,6 +351,7 @@ internal class ZlibBaseStream : Stream, IStreamStack { throw new ZlibException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Protocol error. AvailableBytesIn={0}, expected 8", _z.AvailableBytesIn + bytesRead ) @@ -364,6 +372,7 @@ internal class ZlibBaseStream : Stream, IStreamStack { throw new ZlibException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Bad CRC32 in GZIP stream. (actual({0:X8})!=expected({1:X8}))", crc32_actual, crc32_expected @@ -375,6 +384,7 @@ internal class ZlibBaseStream : Stream, IStreamStack { throw new ZlibException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Bad size in GZIP stream. (actual({0})!=expected({1}))", isize_actual, isize_expected @@ -413,7 +423,14 @@ internal class ZlibBaseStream : Stream, IStreamStack var verb = (_wantCompress ? "de" : "in") + "flating"; if (_z.Message is null) { - throw new ZlibException(String.Format("{0}: (rc = {1})", verb, rc)); + throw new ZlibException( + String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "{0}: (rc = {1})", + verb, + rc + ) + ); } throw new ZlibException(verb + ": " + _z.Message); } @@ -869,7 +886,12 @@ internal class ZlibBaseStream : Stream, IStreamStack if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END) { throw new ZlibException( - String.Format("Deflating: rc={0} msg={1}", rc, _z.Message) + String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "Deflating: rc={0} msg={1}", + rc, + _z.Message + ) ); } @@ -922,6 +944,7 @@ internal class ZlibBaseStream : Stream, IStreamStack { throw new ZlibException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "{0}flating: rc={1} msg={2}", (_wantCompress ? "de" : "in"), rc, @@ -961,7 +984,12 @@ internal class ZlibBaseStream : Stream, IStreamStack if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END) { throw new ZlibException( - String.Format("Deflating: rc={0} msg={1}", rc, _z.Message) + String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "Deflating: rc={0} msg={1}", + rc, + _z.Message + ) ); } } @@ -1050,7 +1078,12 @@ internal class ZlibBaseStream : Stream, IStreamStack if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END) { throw new ZlibException( - String.Format("Deflating: rc={0} msg={1}", rc, _z.Message) + String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "Deflating: rc={0} msg={1}", + rc, + _z.Message + ) ); } @@ -1105,6 +1138,7 @@ internal class ZlibBaseStream : Stream, IStreamStack { throw new ZlibException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "{0}flating: rc={1} msg={2}", (_wantCompress ? "de" : "in"), rc, @@ -1144,7 +1178,12 @@ internal class ZlibBaseStream : Stream, IStreamStack if (rc != ZlibConstants.Z_OK && rc != ZlibConstants.Z_STREAM_END) { throw new ZlibException( - String.Format("Deflating: rc={0} msg={1}", rc, _z.Message) + String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, + "Deflating: rc={0} msg={1}", + rc, + _z.Message + ) ); } } diff --git a/src/SharpCompress/Compressors/Deflate/ZlibCodec.cs b/src/SharpCompress/Compressors/Deflate/ZlibCodec.cs index 7c49c780..b00f93b8 100644 --- a/src/SharpCompress/Compressors/Deflate/ZlibCodec.cs +++ b/src/SharpCompress/Compressors/Deflate/ZlibCodec.cs @@ -696,6 +696,7 @@ internal sealed class ZlibCodec { throw new ZlibException( string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Invalid State. (pending.Length={0}, pendingCount={1})", dstate.pending.Length, dstate.pendingCount diff --git a/src/SharpCompress/Compressors/Deflate/ZlibStream.cs b/src/SharpCompress/Compressors/Deflate/ZlibStream.cs index 417c3283..bfdd82cd 100644 --- a/src/SharpCompress/Compressors/Deflate/ZlibStream.cs +++ b/src/SharpCompress/Compressors/Deflate/ZlibStream.cs @@ -107,6 +107,7 @@ public partial class ZlibStream : Stream { throw new ZlibException( string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Don't be silly. {0} bytes?? Use a bigger buffer, at least {1}.", value, ZlibConstants.WorkingBufferSizeMin diff --git a/src/SharpCompress/Compressors/Lzw/LzwStream.Async.cs b/src/SharpCompress/Compressors/Lzw/LzwStream.Async.cs index c6103e10..3303bbd9 100644 --- a/src/SharpCompress/Compressors/Lzw/LzwStream.Async.cs +++ b/src/SharpCompress/Compressors/Lzw/LzwStream.Async.cs @@ -38,6 +38,7 @@ public partial class LzwStream { throw new IncompleteArchiveException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Wrong LZW header. Magic bytes don't match. 0x{0:x2} 0x{1:x2}", hdr[0], hdr[1] @@ -325,6 +326,7 @@ public partial class LzwStream { throw new IncompleteArchiveException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Wrong LZW header. Magic bytes don't match. 0x{0:x2} 0x{1:x2}", hdr[0], hdr[1] diff --git a/src/SharpCompress/Compressors/Lzw/LzwStream.cs b/src/SharpCompress/Compressors/Lzw/LzwStream.cs index 7fc429f5..e09e4397 100644 --- a/src/SharpCompress/Compressors/Lzw/LzwStream.cs +++ b/src/SharpCompress/Compressors/Lzw/LzwStream.cs @@ -64,6 +64,7 @@ public partial class LzwStream : Stream { throw new IncompleteArchiveException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Wrong LZW header. Magic bytes don't match. 0x{0:x2} 0x{1:x2}", hdr[0], hdr[1] @@ -397,6 +398,7 @@ public partial class LzwStream : Stream { throw new IncompleteArchiveException( String.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Wrong LZW header. Magic bytes don't match. 0x{0:x2} 0x{1:x2}", hdr[0], hdr[1] diff --git a/src/SharpCompress/IO/MarkingBinaryReader.cs b/src/SharpCompress/IO/MarkingBinaryReader.cs index 49d9fe5a..85902263 100644 --- a/src/SharpCompress/IO/MarkingBinaryReader.cs +++ b/src/SharpCompress/IO/MarkingBinaryReader.cs @@ -46,6 +46,7 @@ internal class MarkingBinaryReader(Stream stream) { throw new InvalidFormatException( string.Format( + global::SharpCompress.Common.Constants.DefaultCultureInfo, "Could not read the requested amount of bytes. End of stream reached. Requested: {0} Read: {1}", count, bytes.Length diff --git a/src/SharpCompress/Writers/Tar/TarWriter.cs b/src/SharpCompress/Writers/Tar/TarWriter.cs index b9b6c074..12775903 100644 --- a/src/SharpCompress/Writers/Tar/TarWriter.cs +++ b/src/SharpCompress/Writers/Tar/TarWriter.cs @@ -65,7 +65,11 @@ public partial class TarWriter : AbstractWriter { filename = filename.Replace('\\', '/'); +#if LEGACY_DOTNET var pos = filename.IndexOf(':'); +#else + var pos = filename.IndexOf(':', StringComparison.Ordinal); +#endif if (pos >= 0) { filename = filename.Remove(0, pos + 1); diff --git a/src/SharpCompress/Writers/Zip/ZipWriter.cs b/src/SharpCompress/Writers/Zip/ZipWriter.cs index a05e8c34..26ee920d 100644 --- a/src/SharpCompress/Writers/Zip/ZipWriter.cs +++ b/src/SharpCompress/Writers/Zip/ZipWriter.cs @@ -133,7 +133,11 @@ public partial class ZipWriter : AbstractWriter { filename = filename.Replace('\\', '/'); +#if LEGACY_DOTNET var pos = filename.IndexOf(':'); +#else + var pos = filename.IndexOf(':', StringComparison.Ordinal); +#endif if (pos >= 0) { filename = filename.Remove(0, pos + 1);