Skip to content

refactor: make ZipEntryInfo and related ZIP internals internal #39

@hooyao

Description

@hooyao

Background

ZipEntryInfo is a ZIP-format-specific struct that should not be part of the public API surface of Infrastructure.Archives.Zip. The multi-format architecture (ZIP + RAR + future formats) exposes format-agnostic interfaces (IArchiveStructureBuilder, IArchiveEntryExtractor, IPrefetchStrategy) through the Domain layer — format-specific types like ZipEntryInfo are implementation details.

Currently ZipEntryInfo is public, and it is embedded in the method signatures of IZipReader, ZipFormatMetadataStore, etc., which forces those types to also be public. None of these types are consumed outside the Infrastructure.Archives.Zip assembly (except via DI registration in Program.cs and integration tests).

Why

  • Encapsulation: ZIP internals should not leak into the public API. Other assemblies should interact through Domain interfaces only.
  • Freedom to change: internal types can be refactored without breaking API contracts.
  • Consistency: RAR provider types (RarStructureBuilder, RarEntryExtractor) are already implementation details behind Domain interfaces.

Scope

The following types need to change from public to internal (cascading dependency chain):

Type File Reason
ZipEntryInfo ZipEntryInfo.cs Primary target — format-specific metadata struct
IZipReader IZipReader.cs Method signature exposes ZipEntryInfo
ZipReader ZipReader.cs Implements IZipReader
IZipReaderFactory IZipReaderFactory.cs Returns IZipReader
ZipReaderFactory ZipReaderFactory.cs Implements IZipReaderFactory
ZipFormatMetadataStore ZipFormatMetadataStore.cs Methods expose ZipEntryInfo
ZipEntryExtractor ZipEntryExtractor.cs Constructor takes IZipReaderFactory + ZipFormatMetadataStore
ZipStructureBuilder ZipStructureBuilder.cs Constructor takes IZipReaderFactory + ZipFormatMetadataStore
ZipPrefetchStrategy ZipPrefetchStrategy.cs Constructor takes ZipFormatMetadataStore

How

  1. Change all 9 types from public to internal
  2. Add InternalsVisibleTo to ZipDrive.Infrastructure.Archives.Zip.csproj:
    <InternalsVisibleTo Include="ZipDrive.Cli" />
    <InternalsVisibleTo Include="ZipDrive.Infrastructure.Caching.Tests" />
    (Already has entries for ZipDrive.Infrastructure.Caching and ZipDrive.Infrastructure.Archives.Zip.Tests)
  3. Verify: dotnet build ZipDrive.slnx + dotnet test
  4. Optional follow-up: extract a services.AddZipProvider() extension method to encapsulate DI registration, removing the need for InternalsVisibleTo on Cli

Risk

Low — pure visibility refactor, no behavioral change. All consumers are within the solution. InternalsVisibleTo ensures DI registration and tests continue to work.

Deferred from openspec task 11.1 (multi-format-archive-support) due to the cascade across 9 types + 4 InternalsVisibleTo entries.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions