Skip to content

Tightening build errors by warnings as errors and making more build time issues#1214

Merged
adamhathcock merged 28 commits intomasterfrom
adam/fix-editorconfig-errors
Feb 16, 2026
Merged

Tightening build errors by warnings as errors and making more build time issues#1214
adamhathcock merged 28 commits intomasterfrom
adam/fix-editorconfig-errors

Conversation

@adamhathcock
Copy link
Owner

@adamhathcock adamhathcock commented Feb 13, 2026

This pull request introduces a number of improvements to code analysis, analyzer configuration, and code quality in both the build system and main source code. The most significant changes include stricter analyzer enforcement, enhanced culture-invariant string handling, and improvements to async and memory handling in both configuration and implementation.

Analyzer configuration and enforcement:

  • Many code analysis rules in .editorconfig have been made stricter, with several suggestions promoted to errors (e.g., culture-sensitive operations, string comparison, logging, memory allocation, and async usage). This helps enforce higher code quality and consistency across the codebase.
  • Added granular analyzer configuration for different folders: stricter async/threading analyzers for src/, relaxed or disabled analyzers for build/ scripts, and more lenient rules for tests/.
  • Some style-related analyzers (e.g., IDE0040, IDE0290) have been relaxed from error to suggestion, reducing noise for non-critical style issues. [1] [2]

Build and analyzer infrastructure:

  • Removed <RunAnalyzersDuringLiveAnalysis> and <RunAnalyzersDuringBuild> from Directory.Build.props, likely to ensure analyzers always run during builds and live analysis is not explicitly disabled.

Culture-invariant and string handling improvements:

  • In build/Program.cs, all ToLower() and string operations now explicitly specify CultureInfo.InvariantCulture or StringComparison.Ordinal to avoid culture-specific bugs and improve reliability. [1] [2] [3] [4] [5]
  • In src/SharpCompress/Archives/ArchiveVolumeFactory.cs, ToString() now uses a default culture info for consistent string formatting.

Async and exception handling improvements:

  • In build/Program.cs, exception handling for git commands is now more precise, throwing InvalidOperationException instead of a generic Exception.
  • Added braces to single-line if statements for better readability and maintainability.
  • In src/SharpCompress/Archives/GZip/GZipArchive.Async.cs, simplified async writer construction, removing unnecessary options wrapping.

General code robustness:

  • Improved null/empty checks and parsing logic in benchmark parsing and memory/time value functions, making the code more robust and explicit. [1] [2] [3]

These changes collectively improve code reliability, maintainability, and enforce higher standards for both production and test code.

@adamhathcock adamhathcock marked this pull request as ready for review February 16, 2026 12:27
Copilot AI review requested due to automatic review settings February 16, 2026 12:27
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Feb 16, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (36 files)
  • .editorconfig
  • tests/SharpCompress.Test/Rar/RarArchiveAsyncTests.cs
  • tests/SharpCompress.Test/Rar/RarArchiveTests.cs
  • tests/SharpCompress.Test/Rar/RarReaderAsyncTests.cs
  • tests/SharpCompress.Test/Rar/RarReaderTests.cs
  • tests/SharpCompress.Test/SevenZip/SevenZipArchiveTests.cs
  • tests/SharpCompress.Test/Streams/LzwStreamAsyncTests.cs
  • tests/SharpCompress.Test/Streams/SharpCompressStreamErrorAsyncTest.cs
  • tests/SharpCompress.Test/Streams/SharpCompressStreamSeekAsyncTest.cs
  • tests/SharpCompress.Test/Streams/SharpCompressStreamSeekTest.cs
  • tests/SharpCompress.Test/Tar/TarArchiveAsyncTests.cs
  • tests/SharpCompress.Test/Tar/TarArchiveTests.cs
  • tests/SharpCompress.Test/UtilityTests.cs
  • tests/SharpCompress.Test/WriterTests.cs
  • tests/SharpCompress.Test/Xz/XZBlockAsyncTests.cs
  • tests/SharpCompress.Test/Xz/XZBlockTests.cs
  • tests/SharpCompress.Test/Xz/XZHeaderAsyncTests.cs
  • tests/SharpCompress.Test/Xz/XZHeaderTests.cs
  • tests/SharpCompress.Test/Xz/XZIndexAsyncTests.cs
  • tests/SharpCompress.Test/Xz/XZIndexTests.cs
  • tests/SharpCompress.Test/Xz/XZStreamAsyncTests.cs
  • tests/SharpCompress.Test/Zip/Zip64AsyncTests.cs
  • tests/SharpCompress.Test/Zip/Zip64Tests.cs
  • tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcAsyncTests.cs
  • tests/SharpCompress.Test/Zip/ZipMemoryArchiveWithCrcTests.cs
  • src/SharpCompress/Archives/GZip/GZipArchive.Async.cs
  • src/SharpCompress/Archives/GZip/GZipArchive.cs
  • src/SharpCompress/Archives/Rar/RarArchive.Factory.cs
  • src/SharpCompress/Archives/SevenZip/SevenZipArchive.Factory.cs
  • src/SharpCompress/Archives/SevenZip/SevenZipArchive.cs
  • src/SharpCompress/Archives/Tar/TarArchive.Async.cs
  • src/SharpCompress/Archives/Tar/TarArchive.cs
  • src/SharpCompress/Archives/Zip/ZipArchive.Async.cs
  • src/SharpCompress/Archives/Zip/ZipArchive.cs
  • src/SharpCompress/Compressors/Xz/XZStream.cs
  • src/SharpCompress/Compressors/ZStandard/CompressionStream.cs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens build quality by enabling warnings as errors and fixing numerous code quality issues that were previously allowed. The changes remove dead code, improve resource management with proper disposal patterns, standardize parameter naming, introduce a ThrowHelper utility for consistent null checks, and ensure culture-invariant string operations.

Changes:

  • Enabled stricter compiler analysis by removing RunAnalyzersDuringLiveAnalysis/RunAnalyzersDuringBuild suppressions
  • Removed obsolete DeflateCompressionLevel property and updated tests to use CompressionLevel
  • Added ThrowHelper utility class for consistent argument validation across .NET versions
  • Improved resource disposal with proper using declarations for IDisposable types
  • Removed extensive debug code, unused fields, and nullable suppressions throughout the codebase

Reviewed changes

Copilot reviewed 221 out of 221 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Directory.Build.props Enabled analyzer warnings during build and live analysis
src/SharpCompress/ThrowHelper.cs New helper class for argument validation across .NET versions
src/SharpCompress/Writers/Zip/ZipWriterEntryOptions.cs Removed obsolete DeflateCompressionLevel property
tests/**/*.cs Added using declarations, removed commented debug code, updated to use CompressionLevel
src/**/Async.cs Improved async disposal patterns with proper base.DisposeAsync() calls
src/**/*.cs Removed #nullable disable pragmas, unused fields, debug code, added using declarations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants