Port framework improvements from backend and split into eleven packages - #1
Merged
Merged
Conversation
MagicCSharp was extracted from the backend in June and the two diverged; every shared file differed. This brings the backend's improvements across and splits the packages so a consumer takes only what it uses. Packages Six new: AspNetCore, Scheduling, Data.EntityFramework, Data.Postgres, Testing and Testing.Database. Core drops from six dependencies to three and no longer pulls in ASP.NET Core or distributed locking; Data no longer pulls in Entity Framework, so a domain project can reference the repository interfaces without taking on a persistence library; Testing has no xUnit or Testcontainers, so wanting FakeClock does not mean wanting Docker. Data One IRepository<TEntity, TKey, TEdit, TFilter> replaces the two interfaces that hardcoded long. Soft delete, pagination and search become opt-in interfaces with base classes for both key shapes. Adds GetKeys, batch update by dictionary and by list, delete by filter, untracked reads, and the re-read after write that populates navigation properties. MagicDbContext stores enums by name (including inside JSON columns) so inserting an enum member no longer changes what existing rows mean, and normalizes timestamps to UTC. The Postgres package adds a pooled context factory that fails at startup on a bad connection string, a design-time factory for dotnet ef, and a command interceptor covering the query predicates and ExecuteUpdate/Delete that never reach SaveChanges. Testing New. A clock you move by hand, ids derived from it, an event dispatcher that runs handlers inline so assertions need no sleeping, a re-entrant in-memory lock, and a base class for repository tests against real PostgreSQL in Testcontainers. Fixes - AddMagicUseCases picked implementations with FirstOrDefault, so two implementations meant one was chosen silently by reflection order. Now throws and names both. - The same scan only saw already-loaded assemblies, so use cases in an untouched project were never registered. - LocalEventDispatcher blocked while Kafka and SQS are fire-and-forget, so a handler re-entering its emitter's lock worked locally and deadlocked in production. - ScheduledBackgroundService logged its next run from the wall clock while scheduling from the injected IClock. - Core pinned Microsoft.AspNetCore.Http.Abstractions 2.2.0. Tooling tools/ holds AddEntity, ValidateConventions and SyncAllProjects as single-file programs, keyed off magiccsharp.json rather than hardcoded paths so they work in any repository using the layout. Tests 47, where there were none. Libraries stay on net9.0 so net9 and net10 apps can both consume them. See CHANGELOG.md for the full list and the migration guide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
MagicCSharp was extracted from the backend in June and the two diverged; every shared file differed. This brings the backend's improvements across and splits the packages so a consumer takes only what it uses.
Packages
Six new: AspNetCore, Scheduling, Data.EntityFramework, Data.Postgres, Testing and Testing.Database. Core drops from six dependencies to three and no longer pulls in ASP.NET Core or distributed locking; Data no longer pulls in Entity Framework, so a domain project can reference the repository interfaces without taking on a persistence library; Testing has no xUnit or Testcontainers, so wanting FakeClock does not mean wanting Docker.
Data
One IRepository<TEntity, TKey, TEdit, TFilter> replaces the two interfaces that hardcoded long. Soft delete, pagination and search become opt-in interfaces with base classes for both key shapes. Adds GetKeys, batch update by dictionary and by list, delete by filter, untracked reads, and the re-read after write that populates navigation properties.
MagicDbContext stores enums by name (including inside JSON columns) so inserting an enum member no longer changes what existing rows mean, and normalizes timestamps to UTC. The Postgres package adds a pooled context factory that fails at startup on a bad connection string, a design-time factory for dotnet ef, and a command interceptor covering the query predicates and ExecuteUpdate/Delete that never reach SaveChanges.
Testing
New. A clock you move by hand, ids derived from it, an event dispatcher that runs handlers inline so assertions need no sleeping, a re-entrant in-memory lock, and a base class for repository tests against real PostgreSQL in Testcontainers.
Fixes
Tooling
tools/ holds AddEntity, ValidateConventions and SyncAllProjects as single-file programs, keyed off magiccsharp.json rather than hardcoded paths so they work in any repository using the layout.
Tests
47, where there were none.
Libraries stay on net9.0 so net9 and net10 apps can both consume them. See CHANGELOG.md for the full list and the migration guide.