Skip to content

Change ArchiveEncoding to interface.#1117

Merged
adamhathcock merged 6 commits intomasterfrom
adam/rework-archive-encoding
Jan 8, 2026
Merged

Change ArchiveEncoding to interface.#1117
adamhathcock merged 6 commits intomasterfrom
adam/rework-archive-encoding

Conversation

@adamhathcock
Copy link
Owner

Simplify class. Question what to do about Forced and complex access. Was custom encoder used?

Should I have the interface use a Func then default to what I use but allow for anything?

Started by #1115

Copilot AI review requested due to automatic review settings January 7, 2026 08:45
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 refactors the ArchiveEncoding class to use an interface pattern (IArchiveEncoding) to simplify the encoding handling throughout SharpCompress. The main changes include:

  • Introduces IArchiveEncoding interface with three properties: Default, Password, and UTF8
  • Converts ArchiveEncoding to implement the new interface
  • Removes Forced and CustomDecoder properties and their associated logic
  • Replaces method calls (GetEncoding(), GetPasswordEncoding(), DecodeUTF8()) with direct property access
  • Adds extension methods for common encoding operations (Encode, Decode)
  • Updates all references throughout the codebase to use IArchiveEncoding instead of concrete type

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/SharpCompress/Common/ArchiveEncoding.cs Core refactoring: introduces IArchiveEncoding interface, implements it in ArchiveEncoding class, removes Forced and CustomDecoder properties, adds extension methods
src/SharpCompress/Common/OptionsBase.cs Updates ArchiveEncoding property to use IArchiveEncoding interface type
src/SharpCompress/Common/FilePart.cs Updates field and constructor parameter types from ArchiveEncoding to IArchiveEncoding
src/SharpCompress/Common/GZip/GZipFilePart.cs Updates constructor parameter type to IArchiveEncoding
src/SharpCompress/Common/SevenZip/SevenZipFilePart.cs Updates constructor parameter type to IArchiveEncoding
src/SharpCompress/Common/Arc/ArcEntryHeader.cs Updates property and constructor parameter types to IArchiveEncoding
src/SharpCompress/Common/Ace/Headers/AceHeader.cs Updates field and constructor parameter types to IArchiveEncoding
src/SharpCompress/Common/Ace/Headers/AceMainHeader.cs Updates constructor parameter type to IArchiveEncoding
src/SharpCompress/Common/Ace/Headers/AceFileHeader.cs Updates constructor parameter type to IArchiveEncoding
src/SharpCompress/Common/Rar/Headers/RarHeader.cs Updates field and method parameter types to IArchiveEncoding
src/SharpCompress/Common/Tar/TarEntry.cs Updates method parameter type to IArchiveEncoding
src/SharpCompress/Common/Tar/TarHeaderFactory.cs Updates method parameter type to IArchiveEncoding
src/SharpCompress/Common/Tar/Headers/TarHeader.cs Updates field and constructor parameter types; replaces GetEncoding() calls with .Default property access
src/SharpCompress/Common/Zip/Headers/ZipFileEntry.cs Updates field and constructor parameter types to IArchiveEncoding
src/SharpCompress/Common/Zip/Headers/LocalEntryHeader.cs Updates constructor parameter type; replaces DecodeUTF8() with UTF8.GetString()
src/SharpCompress/Common/Zip/Headers/DirectoryEntryHeader.cs Updates constructor parameter type; replaces DecodeUTF8() with UTF8.GetString()
src/SharpCompress/Common/Zip/PkwareTraditionalEncryptionData.cs Updates field and constructor parameter types; replaces GetPasswordEncoding() with .Password property access
src/SharpCompress/Common/Zip/ZipHeaderFactory.cs Updates field and constructor parameter types to IArchiveEncoding
src/SharpCompress/Common/Zip/SeekableZipHeaderFactory.cs Updates constructor parameter type to IArchiveEncoding
src/SharpCompress/Common/Zip/StreamingZipHeaderFactory.cs Updates constructor parameter type to IArchiveEncoding
src/SharpCompress/Writers/Zip/ZipCentralDirectoryEntry.cs Updates field and constructor parameter types; replaces GetEncoding() with .Default property access
src/SharpCompress/Writers/Zip/ZipWriter.cs Replaces GetEncoding() call with .Default property access
src/SharpCompress/Writers/GZip/GZipWriter.cs Replaces GetEncoding() call with .Default property access
src/SharpCompress/Readers/Ace/AceReader.cs Updates field type to IArchiveEncoding

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

Copilot AI review requested due to automatic review settings January 7, 2026 10:39
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

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.


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

Copilot AI review requested due to automatic review settings January 7, 2026 11:12
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

Copilot reviewed 24 out of 24 changed files in this pull request and generated 6 comments.


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

@adamhathcock
Copy link
Owner Author

This is instead of #1116

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