Change ArchiveEncoding to interface.#1117
Conversation
… do about Forced and complex access
There was a problem hiding this comment.
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
IArchiveEncodinginterface with three properties:Default,Password, andUTF8 - Converts
ArchiveEncodingto implement the new interface - Removes
ForcedandCustomDecoderproperties 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
IArchiveEncodinginstead 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
This is instead of #1116 |
Simplify class. Question what to do about Forced and complex access. Was custom encoder used?
Should I have the interface use a
Functhen default to what I use but allow for anything?Started by #1115