Skip to content

Reshape the public API before the first release #15

Description

@vaceslav

From the pre-release review. Breaking changes are cheap now (0.x, nothing published) and expensive after; decide each before dotnet pack goes to nuget.org.

Blockers

  • One exception model with a library base type. Today the same bad plan is ArgumentException from TabularExtractor.Start and TabularStructureException from TabularImporter.Import(Stream…); corrupt files and exceeded ceilings are BCL InvalidDataException; malformed XML leaks XmlException. Proposal: TabularException → TabularFormatException (unreadable/unsupported/corrupt, with a code), TabularLimitException (a bound was hit — which one), TabularStructureException (whole-run fault, with a code), MappingPlanException (carries the MappingFaults). Keep ArgumentException for programmer errors only.
  • Fewer namespaces. Seven today (Abstractions, Csv, Xlsx, Analysis, Mapping, Extraction, Import); the documented import needs five usings and ~15 types. Proposal: the workflow in TriasDev.Tabular, format-specific cursors/options in .Csv / .Xlsx.

High

  • Internalise implementation types: ColumnProfiler, DistinctBudget, HypothesisBuilder, CsvDialectDetector (add InternalsVisibleTo for tests where needed).
  • Public error-code constants (ErrorCodes.ValueRequired = "value.required", …) so callers stop copying strings; keep ErrorCodeCatalogTests checking them against the guide.
  • A plan without a UI: e.g. MappingPlan.ByHeader(schema, profile, …) matching headers to field names (case/space/underscore-insensitive), filling SourceHeader from the profile. Needed for a 15-line happy path.
  • Unsupported formats: TabularFormat has no way to say "not a format we read"; TabularFile.Detect/Open should recognise OLE2 (.xls), xlsb, ods (for now), and non-text binaries and throw the format exception.
  • Stream ownership / leaveOpen is inconsistent: Import(Stream…) always closes, ExtractionSession is IDisposable but owns nothing, TabularFile.Open cannot pass cursor options. One rule for every entry point.
  • Cancellation token placement: captured at construction in some layers, per call in others (cursor ReadRow, analyzer). Pick one convention.
  • ITabularCursor contract: versioning story for a public interface (default members), and put the csv dialect somewhere other than a CsvCursor cast.

Medium

  • Culture spelled three ways ("", "invariant", null) across profile, hypotheses and plan — a top hypothesis's culture cannot be copied into a plan as is.
  • Entry points differ per layer (new TabularAnalyzer(opts).Analyze vs static TabularExtractor.Start vs static TabularImporter.Import); align verbs and shapes.
  • ImportRun<T> is an IEnumerable that can be enumerated once; make that explicit (or not an IEnumerable) and even out InChunks/All naming.
  • PrecheckFinding.Detail is English prose; MappingFault, RowError, PrecheckFinding are three shapes for "a problem" — align fields (code, field, column, row, rows affected, values).
  • Generic names that collide in consumer code: TextField, DateField, Pattern, Rule.
  • Options records validate nothing (negative bounds, empty cultures) and cannot be reached from TabularFile.Open.
  • CsvDialect override is all-or-nothing (must restate encoding + delimiter + provenance to change one).
  • Cheap single-sheet analysis, sheet addressing by name, sheet visibility (docs/IDEAS.md).

Low

  • Row counters are int in six places and long in one — pick long or document the int ceiling.
  • FileProfile.Diagnostics / ImportRun.Summary expose live mutable objects.
  • Records with collection/delegate members get reference equality (TargetField, ColumnBinding, Pattern, AllowedValues) — seal equality semantics or use classes.
  • Fluent naming (Matching/AtLeast) vs constraint names (Pattern/MinValue); range rules silently no-op on non-numeric fields.
  • Pattern matches anywhere in the value (unanchored) — document or anchor.
  • After v1 (additive): async/IAsyncEnumerable import for blob streams, analyse-by-path, raw preview grid, IDataReader interop.

Tooling to lock the result in: Microsoft.CodeAnalysis.PublicApiAnalyzers (PublicAPI.Shipped/Unshipped.txt) and package validation — see #3.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions