fix(archive): sharpcompress 1.0 api-sprung fail-closed abfangen#104
fix(archive): sharpcompress 1.0 api-sprung fail-closed abfangen#104tomtastisch merged 6 commits intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4bd7f74a37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
This PR addresses a breaking API change in SharpCompress when upgrading from version 0.46.x to 1.0.0. The changes implement a reflection-based compatibility layer that works with both API versions by dynamically resolving method names at runtime - trying the old method name first (OpenArchive/OpenWriter), then falling back to the new name (Open), and throwing MissingMethodException if neither exists.
Changes:
- Created a new compatibility layer in production code (
ArchiveInternals.vb) using reflection-based method resolution with explicit BindingFlags - Created a parallel test support compatibility class (
SharpCompressApiCompat.cs) for test infrastructure - Migrated all direct SharpCompress API calls (both archive reading and writing) to use the compatibility layers
- Enhanced exception handling to catch reflection-related exceptions (
MissingMethodException,TargetInvocationException)
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/FileTypeDetection/Infrastructure/ArchiveInternals.vb |
Added reflection-based compatibility methods GetOpenCompatMethod, OpenArchiveFactoryCompat, and OpenGZipArchiveCompat with fail-closed exception handling |
tests/FileTypeDetectionLib.Tests/Support/SharpCompressApiCompat.cs |
New test support class providing compatibility wrappers for OpenArchive, OpenZipArchive, and OpenWriter methods |
tests/FileTypeDetectionLib.Tests/Support/ArchivePayloadFactory.cs |
Migrated all WriterFactory.OpenWriter calls to use SharpCompressApiCompat.OpenWriter |
tests/FileTypeDetectionLib.Tests/Unit/SharpCompressArchiveBackendUnitTests.cs |
Updated test helper method to use compatibility layer for writer creation |
tests/FileTypeDetectionLib.Tests/Unit/SharpCompressEntryModelNonNullUnitTests.cs |
Migrated archive/writer creation to compatibility layer, removed unused import |
tests/FileTypeDetectionLib.Tests/Unit/CoreAndArchiveInternalsFailClosedUnitTests.cs |
Migrated archive opening to compatibility layer, removed unused imports |
tests/FileTypeDetectionLib.Tests/Unit/ArchiveInternalsNestedBranchUnitTests.cs |
Migrated both archive opening and writer creation to compatibility layer, removed unused import |
Ziel & Scope
Diese PR behebt den SharpCompress-API-Sprung bei Canary-Updates auf
1.0.0und stellt sicher, dass sowohl Produktionscode als auch Test-Helfer gegen0.46.xund1.0.0deterministisch kompatibel bleiben.Umgesetzte Aufgaben (abhaken)
OpenArchive/Open) umgestellt.OpenWriter/Open) kompatibel gemacht.SharpCompress 1.0.0erfolgreich ausgeführt.Nachbesserungen aus Review (iterativ)
IArchiveEntry-Import) behoben.WriterFactory.OpenWriter) auf Kompat-Layer umgestellt.dotnet format --verify-no-changes) durch korrigierteusing-Reihenfolge erfüllt.Security- und Merge-Gates
security/code-scanning/toolsmuss vor Merge auf0 offene Alertsstehen.Evidence (auditierbar)
dotnet format FileClassifier.sln --verify-no-changes-> erfolgreichdotnet test tests/FileTypeDetectionLib.Tests/FileTypeDetectionLib.Tests.csproj -c Release -v minimal --filter "SharpCompress|ArchiveInternalsNestedBranchUnitTests|CoreAndArchiveInternalsFailClosedUnitTests|ArchiveSharpCompressCompatUnitTests"->35 passedbash -euo pipefail tools/ci/bin/dependency-canary.sh SharpCompress 1.0.0->35 passed(lokaler Canary-Nachweis)DoD (mindestens 2 pro Punkt)
ArchiveInternals.vbnutzt keine statische Bindung mehr an nurOpenArchiveSharpCompress 1.0.0erfolgreichSharpCompressApiCompat.OpenArchive/OpenZipArchivevorhandenSharpCompressApiCompat.OpenWritervorhandenMissingMethodExceptionstatt stiller Fehlinterpretation