Repository navigation
feat(csharp): REST-standard list queries and a default page of 50 - #653
Merged
Merged
Conversation
…ckage The helpers generated routes call (FilterParser, EfCoreFilterDispatch, ValueObjectValidator, ConstraintErrors and the rest of HelperRuntime.Files) move from MetaObjects.Codegen/Runtime/ into a new MetaObjects.AspNetCore project and NuGet package, namespace MetaObjects.AspNetCore, which references ASP.NET Core and EF Core and no MetaObjects package. MetaObjects.Codegen drops its EF Core and ASP.NET Core references, so the dotnet meta tool packs 6 DLLs instead of 14. ExtractObject and M2MResolver stay in MetaObjects.Codegen as core. - The packaged routes generator writes `using MetaObjects.AspNetCore;`, so regen moves the import; owned copies keep Codegen.Runtime. Eject reads the helper source embedded by link in MetaObjects.Codegen. - gen and verify --codegen warn (advisory) when a generated file imports MetaObjects.AspNetCore and its project does not reference the package, and when generated output still imports the helpers from MetaObjects.Codegen.Runtime. - CHANGELOG upgrade note, design note, docs, agent-context goldens, showcase regen, and the publish workflow, prerelease script and RELEASING pack five C# packages.
A generated entity, TPH or projection list in a project that sets no api.pagination returned every row when the request carried no limit. It now answers the first 50 (ApiSettings.DefaultPageLimit), the default of every port; an explicit limit is served as asked. Without the setting a malformed limit or offset is 400 pagination.invalid_value and limit=0 is an empty page, as with it. The dotnet meta verify --codegen advisory unbounded-list-pages is retired. The C# generated lane runs the shared list-query sub-corpus: the paging and refusal scenarios the routes answer today; search, or/and and the named refusals are listed by name until R-CS. Docs, upgrade guide, CHANGELOG, goldens and the showcase routes file follow.
MetaObjects.AspNetCore gains ListQueryParser, a port of runtime-ts's parseListQuery. It reads or/and groups to a depth of five, search, sort with @sortableDefaultOrder, and page bounds. It refuses bare-field parameters, a leading %, and malformed values, naming each refusal with the shared wire codes and details. Faults are reported in the shared order. FilterValueFormat ports the format checks and the UTC spelling of timestamp bounds. EfCoreFilterDispatch.Apply turns the parsed tree and the search into one Where each. Each generated <Entity>FilterAllowlist now also carries Rules, Sort and FieldNames. FieldNames leaves out credentials. The sortable set follows the TypeScript rule: @Sortable, otherwise @filterable. FilterRules, SortRules and FieldNames are public, so ListQueryConformanceTests can derive the allowlist the generator emits. That runner passes all 95 cases in fixtures/list-query-conformance/. The allowlist now imports the helper runtime, so it carries the eject marker. Instant timestamps bind as DateTimeOffset at offset zero, and local-time timestamps bind as an unspecified DateTime. The generated routes still call the flat FilterParser. R-CS-2 wires them to the new parser.
… invalid_json and invalid_id (R-CS-2) Every generated C# list route (entity, projection, report, TPH base and subtype) reads its query through ListQueryParser and applies it with EfCoreFilterDispatch.Apply: ?search, filter[or]/filter[and] groups, and the bare-field, leading-wildcard and nesting refusals. Sorting reads one route-local SortRules table. A body that is not JSON answers 400 invalid_json and a path id the key cannot hold answers 400 invalid_id, through the new RouteErrors helper that eject copies with the others. The C# generated lane now runs the whole list-query/ sub-corpus, and KNOWN_GAPS G2 is closed.
…reads the parsed bounds Review fixes on the R-CS bundle: - The filter allowlist now emits the helper-typed rule table the routes hand to ListQueryParser, so ejecting only one of the two put two copies of the helper types in one build. Eject and eject --undo now move both together. - A report list read limit/offset twice, once in ListQueryParser and again from the raw query. It now reads the parsed bounds and keeps only the report's own checks (limit=0, the row cap), as the TypeScript report page does. - The pre-1.3.0 import warning now leads with the regenerate advice, since a project on the packaged generators sees it too. - Cli tests updated for the allowlist import and the ListQuery owned edit. - KNOWN_GAPS G10 records that the C# routes sort on more fields than the contract's sortable set; narrowing it is breaking and waits on a ruling.
…t for list and report pages
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.
What Changed
ListQueryParserin theMetaObjects.AspNetCorepackage. It handles?search=,filter[or]/filter[and]groups to a depth of five, sort with@sortableDefaultOrder, and page bounds, and it answers the named refusals (filter.bare_field,invalid_json,invalid_id, and others). The generated lane runs the sharedlist-query/corpus, and the flatFilterParserpath is marked[Obsolete].limitanswers 50 rows (ApiSettings.DefaultPageLimit) when the project sets noapi.pagination. Without that setting, a malformedlimitoroffsetis now400 pagination.invalid_valueinstead of being ignored. This is a breaking change, and the upgrade note is inchangelog.d.MetaObjects.Codegen/Runtimeinto the newMetaObjects.AspNetCorepackage.MetaObjects.Codegenand thedotnet metatool no longer reference EF Core or ASP.NET Core.genandverifywarn when an app lacks the new reference, eject copies the helpers intocodegen/runtime, and the publish workflow and prerelease script pack the new package.Gate: this PR took 1 no-mistakes run (one review fix round, on the decision to deprecate rather than remove the flat-filter path).
Validation
Risk Assessment
✅ Low: The fix round only adds [Obsolete] to the unused flat-filter path, repoints tests at the live ListQuery overloads and adds a changelog note. The live path is unchanged, no generated code or in-package caller uses the obsolete members, and I found no new defects. I read only the fix-round diff and its surroundings, not the earlier-round files.
Testing
Baseline affected run passed and was not repeated. The C# generated list lane ran 21 of 21 shared list-query scenarios over HTTP against a real Postgres, covering the default page of 50, page past 50, filter or/and groups, the nesting cap, bare-field, leading-wildcard, pagination, invalid_json, invalid_id and constraint refusals. A disposable app built with the local CLI showed the helper-runtime warning on gen and verify when the reference is missing. The same app fails to compile without the reference and builds with it. Dependency graphs carry no EF Core. Overall result: pass, with no failures.
Evidence: C# list-query generated lane: 21/21 pass over HTTP vs Testcontainers Postgres
Evidence: gen warns when app lacks MetaObjects.AspNetCore reference
Evidence: gen with reference: no warning
Evidence: verify --codegen warns without reference
Evidence: app build without reference fails (CS0246)
Evidence: app build with reference succeeds
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
server/csharp/MetaObjects.AspNetCore/EfCoreFilterDispatch.cs:39- The change adds ListQueryParser plus EfCoreFilterDispatch.Apply and Validate(ListQuery), and every generated list route now calls those. The earlier flat-filter path is still carried and shipped in the new MetaObjects.AspNetCore package, and no generated code calls it: FilterParser.Parse, FilterPredicate, FilterParseResult, EfCoreFilterDispatch.ApplyFilter and Validate<T>(FilterParseResult), plus the allowlist's Fields/OpsByField members that only FilterParser reads. It is a second, weaker parser of the same filter grammar (no or/and groups, no bare-field, wildcard or depth refusals). It is also embedded and copied byeject. Nothing in the intent (R-CS-1, R-CS-2, or the package split) requires keeping it. Two tests now check the dead overload instead of the live one: DecimalWireTests.cs:155 and DurationWireTests.cs:171 call Validate(FilterParseResult), and PropertyNamingEmitSitesTests.cs:373-378 calls ApplyFilter. The shared CoerceTo is common to both overloads, but the live Validate(ListQuery) path has no direct decimal or duration operand test of its own. No intent requirement needs the old path; removing it is the smallest honest remedy. Because a hand-written endpoint could call it, whether to keep it as a compatibility surface is a product decision, so ask first. If it stays, repoint those tests at the ListQuery overloads.🔧 Fix applied.
📝 1 wording or comment-placement note left for the author (no fix round spent):
docs/features/api-contract.md:226- Doc named the now-[Obsolete] FilterParser.MaxInList as the C# in-list cap; repointed to ListQueryParser.DefaultMaxInList (the live parser's constant, value 100).✅ **Test** - passed
✅ No issues found.
scripts/ci-local.sh --affected --strict-toolchainsBaseline (already passed, not re-run): scripts/ci-local.sh --affected --strict-toolchainsdotnet test server/csharp/MetaObjects.IntegrationTests/MetaObjects.IntegrationTests.csproj --filter FullyQualifiedName~ApiContractListQueryConformanceTest (21/21 passed; generated C# server driven over HTTP against Testcontainers Postgres 16, covering the 21 fixtures/api-contract-conformance/list-query/scenarios)dotnet build server/csharp/MetaObjects.Cli/MetaObjects.Cli.csproj -o <scratch>/cli (built dotnet meta from the worktree source)In a disposable scratch app: dotnet meta init; codegen/Codegen.csproj ProjectReference to worktree MetaObjects.Codegen; Entity, DbContext, FilterAllowlist, Routes generators run via dotnet meta gen --out gen (warning printed, exit 0)dotnet meta verify metaobjects --codegen --out gen without reference (warning printed; verify exit 0)Added ProjectReference to MetaObjects.AspNetCore and re-ran gen (0 warnings)dotnet build App.csproj with MetaObjects.AspNetCore reference (exit 0) and without it (CS0246 errors on FilterFieldRule, SortFieldRule, MetaObjects), confirming the warning is accurategrep EntityFrameworkCore in built MetaObjects.Cli.deps.json and MetaObjects.Codegen.deps.json (0 refs each)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.