Skip to content

add new Excel provider for local file - #4

Merged
muqimjon merged 36 commits into
releasefrom
main
Feb 28, 2026
Merged

add new Excel provider for local file#4
muqimjon merged 36 commits into
releasefrom
main

Conversation

@muqimjon

Copy link
Copy Markdown
Owner

No description provided.

Both system sheets (__SheetlySchema__ and __SheetlyMigrationsHistory__)
are now hidden from view after creation, as documented in README.
…alls

- Populate _sheetCache in InitializeAsync from single Spreadsheets.Get response
- SheetExistsAsync now returns from cache (0 API calls, was 1 per check)
- GetSheetIdInternal now returns from cache (0 API calls, was 1 per call)
- CreateSheetAsync updates cache after creation
- DeleteSheetAsync removes from cache after deletion
- DropDatabaseAsync uses cache instead of extra Spreadsheets.Get
- Add ISheetsProvider.AppendRowAndGetIdAsync(sheetName, row): Task<int>
- GoogleSheetProvider: set ID cell to =IFERROR(MAX(INDIRECT(...))+1,1),
  parse row number from AppendRow response, read back computed value
- InMemorySheetsProvider: compute MAX(Id)+1 in-memory for test parity
- SheetsSet: use AppendRowAndGetIdAsync for PK tables (2 API calls vs 5)
- Remove GetAndIncrementIdFromCentralSchema — no longer needed
- ID is now computed atomically by Sheets formula, safer for concurrent writes
- Add ISheetsProvider.AppendRowsAsync (1 API call for N rows)
- Add ISheetsProvider.GetMaxIdAsync (read MAX column-A value, 1 API call)
- GoogleSheetProvider: implement both with Values.Append batch and Values.Get
- InMemorySheetsProvider: implement both with in-memory logic
- SheetsSet SaveChanges: for PK tables read MAX once then AppendRowsAsync
  (2 API calls for any batch size, was 2×N with individual appends)
- SheetsSet SaveChanges: for non-PK tables also uses AppendRowsAsync
- SheetsSet: add _snapshots dictionary keyed by entity reference
- ToListAsync: serialize each tracked entity as JSON snapshot on load
- DetectChanges: compare current JSON with original; promote Unchanged
  entities to Modified when any property has changed
- SheetsContext.SaveChangesAsync: call DetectChanges on all sets before
  validating/saving — mirrors EF Core ChangeTracker.DetectChanges()
- Clear _snapshots in SaveChangesInternalAsync alongside other state
- Users no longer need to call context.Set.Update(entity) explicitly
- Add ISheetsProvider.FindRowIndexByKeyAsync: reads column A only to
  locate row index by key value (avoids fetching all row data)
- GoogleSheetProvider: implement with Values.Get on A:A column range
- InMemorySheetsProvider: implement with in-memory column-A scan
- SheetsSet.FindAsync: use FindRowIndexByKeyAsync + GetRowByIndexAsync
  (3 API calls: key-column + header + row, vs 1 call but all rows)
- FindAsync also stores snapshot for auto change tracking
- GoogleSheetProvider: replace single SheetsService with SheetsService[]
- LoadServicesFromJson: auto-detect {} (single) vs [{},{}] (array) format
- Round-robin via Interlocked.Increment + modulo on _serviceIndex
- With N accounts: effective limit scales to N x 60 req/min writes
- Dispose: properly disposes all services
- credentials.json can now hold [{creds1},{creds2},...] for up to 5x quota
…loading

- SheetsSet.Include<TProperty>(Expression<Func<T,TProperty>>): extracts
  property name from lambda at compile time (no magic strings)
- Mirrors EF Core syntax: context.Orders.Include(o => o.Customer)
- String-based Include(string) overload retained for backward compatibility
…ngesAsync

- SheetsContext: implement IAsyncDisposable.DisposeAsync() alongside IDisposable
  (delegates to IAsyncDisposable provider if available, else sync Dispose)
- SheetsContext.SaveChangesAsync: accept optional CancellationToken parameter
  ThrowIfCancellationRequested after local validation, before API calls
- Mirrors EF Core's DbContext.SaveChangesAsync(CancellationToken) signature
… style)

- Add SheetsContextOptions<TContext> : SheetsOptions typed options class
- SheetsContext: add protected ctor(SheetsOptions) storing injected options
- InitializeAsync: prefers constructor options over OnConfiguring override
- ServiceCollectionExtensions.AddSheetsContext: detect ctor with options
  and inject SheetsContextOptions<TContext> (EF Core DI style); fall back
  to parameterless ctor for backward-compatible OnConfiguring contexts
- Enables: public AppContext(SheetsContextOptions<AppContext> opts) : base(opts)
- release-core.yml   : triggered on tags matching core-v*
- release-google.yml : triggered on tags matching google-v*
- release-di.yml     : triggered on tags matching di-v*
- release-cli.yml    : triggered on tags matching cli-v*
Each workflow: builds solution, runs tests, packs the single project,
pushes to NuGet, creates GitHub Release with the package as artifact.
Usage: git tag core-v1.1.0 && git push origin core-v1.1.0
Remove code-level comments throughout codebase, keeping only
brief class/method-level XML documentation. Remove unused
CreateService(GoogleCredential) method from GoogleSheetProvider.
Throw InvalidOperationException if context is not initialized,
preventing confusing NullReferenceException at runtime.
Add ChangeTrackingTests (auto-detect modified, unchanged, AsNoTracking)
and ExpressionIncludeTests (collection, reference, string vs expression).
Document auto change tracking, expression-based Include,
multiple credentials rotation, batch operations, optimized FindAsync,
CancellationToken support, SheetsContextOptions constructor pattern,
IAsyncDisposable, and in-memory sheet metadata cache.
New features added since v1.0.3:
- Automatic change tracking
- Expression-based Include
- Multiple credentials rotation
- Batch append operations
- Optimized FindAsync
- CancellationToken support
- IAsyncDisposable
- SheetsContextOptions constructor pattern
- In-memory sheet metadata cache
- Per-package release workflows
Implement ExcelSheetProvider (ISheetsProvider) for local .xlsx files.
Add ExcelMigrationService with full DropColumn support.
Add UseExcel() extension method on SheetsOptions.
SnapshotBuilder.BuildFromContext is the canonical implementation used
by both SheetsContext and CLI. The static MigrationBuilder in the
Migration namespace was an earlier version with zero callers.
Math.Abs(int.MinValue) throws when _serviceIndex wraps past int.MaxValue.
Use bitmask (& 0x7FFFFFFF) instead to safely clear the sign bit.
Product/Category models, ExcelAppContext and GoogleAppContext.
Interactive menu to test Excel and Google Sheets providers.
Also add Sheetly.DependencyInjection badge to README.
Use AssemblyLoadContext + AssemblyDependencyResolver to load the target
project DLL in full isolation. All Sheetly.Core types (ModelBuilder,
SnapshotBuilder, MigrationBuilder) are now loaded from the project's own
bin directory, eliminating MVID conflicts between the CLI's embedded copy
and the project's freshly compiled copy.

Key changes:
- Add ProjectAssemblyLoadContext (mirrors dotnet-ef isolation pattern)
- Add TypeJsonConverter for System.Type cross-context serialization
- CliHelper: LoadAssemblyIsolated, GetCoreAssembly, GetGoogleAssembly,
  BridgeMigrationOperations, BridgeFromJson<T>, VersionMismatchMessage
- AddCommand, UpdateCommand, RemoveCommand: use isolated ModelBuilder +
  SnapshotBuilder + MigrationBuilder via JSON bridge
- ScriptCommand, RollbackCommand: isolated snapshot loading
- DropCommand, ScaffoldCommand: isolated Sheetly.Google factory so
  contextType satisfies T:SheetsContext constraint

CLI is now version-agnostic: once installed, it works with any future
version of Sheetly packages without requiring reinstallation.
All CLI commands now invoke DesignTimeOperations via reflection.
No Sheetly types cross the AssemblyLoadContext boundary - only JSON strings.
CLI no longer references Sheetly.Core or Sheetly.Google, making it
version-agnostic like dotnet-ef.

- Add DesignTimeOperations (6 static methods returning JSON)
- Rewrite all 7 CLI commands as thin InvokeDesignTime wrappers
- Remove TypeJsonConverter.cs (obsoleted)
- Remove Sheetly.Core/Google project references from CLI
- Add --no-build option to script/drop/scaffold commands
… version

- SnapshotBuilder: IsAutoIncrement only true for numeric PK types (int/long/short/byte etc.)
- SheetsSet: only auto-assign ID when pkColumn.IsAutoIncrement is true
  - string PKs (e.g. Username) are now user-assigned, not overwritten with '1','2'...
- GoogleMigrationService & ExcelMigrationService: ProductVersion reads Sheetly.Core
  assembly version dynamically instead of hardcoded '1.0.0'
…PK tests

- SnapshotBuilder: PK columns always IsRequired=true, IsNullable=false regardless of type
- PrimaryKeyValidator: empty string user-assigned PK now throws validation error
  (auto-increment PKs skip validation when value is default - system assigns)
- Add 5 SnapshotBuilder unit tests for numeric/string PK schema metadata
- Add 5 integration tests (StringPkTests) covering string PK CRUD + validation
- ISheetsProvider: replace GetMaxIdAsync with GetAndIncrementIdAsync(tableName, count)
- GetAndIncrementIdAsync reads/writes CurrentIdValue in __SheetlySchema__
- Batch insert reserves all IDs in one schema update (reduces race condition window)
- Fallback: if CurrentIdValue=0, scans data column A for max (backward compat)
- Remove GetMaxIdAsync and AppendRowAndGetIdAsync from interface (internal detail)
- Add SchemaIdGenerationTests (5 tests covering schema counter, batch, fallback, concurrency)
- Bump all package versions to 1.1.0
…eAsync for direct cell read

- Google Sheets USERENTERED mode stores 'True' as boolean TRUE, returned as 'TRUE'
  Old code: row[7] == 'True' always failed -> function returned 1 every time
  Fix: bool.TryParse handles 'True', 'TRUE', 'true' all correctly
- Google: use GetValueAsync(schema, AC{row}) instead of row[28] for CurrentIdValue
  This avoids row.Count > 28 assumption (Google API omits trailing empty cells)
- Excel/InMemory: same bool.TryParse fix applied for consistency
- DatabaseFacade: converted to C# 12 primary constructor
- RELEASE_NOTES.md: added v1.1.0 section, moved v1.0.x to history, updated roadmap
@muqimjon
muqimjon merged commit e121b81 into release Feb 28, 2026
3 checks passed
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.

1 participant