Skip to content

C# submodules - #5974

Open
lisandroct wants to merge 49 commits into
masterfrom
lisandro/csharp-submodules
Open

lisandroct wants to merge 49 commits into
masterfrom
lisandro/csharp-submodules

Conversation

@lisandroct

@lisandroct lisandroct commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Description of Changes

Implements C# submodules (namespacing), following the proposal and reusing the existing V10 submodule representation.

  • Automatically discovers and registers referenced C# module assemblies.
  • Adds assembly-level [Namespace(typeof(AuthLib.Marker), Accessor = "MyAuth", Name = "auth_data" )] declarations. Accessor controls C# access; optional Name specifies the canonical database namespace. When omitted, the host derives it using the root module’s case-conversion policy. Dependencies without a namespace declaration register in public.
  • Allows the same module assembly to be published independently or used as a dependency, without a separate library build role.
  • Shares .NET 10 contexts across assemblies. Root code accesses ctx.Db.MyAuth.User; library helpers retain ctx.Db.User and use the caller’s context and transaction.
  • Supports namespace-aware tables, indexes, views, query builders, and scheduled reducers/procedures.
  • Generates nested C# client table, reducer, procedure, and subscription accessors using one connection and cache.
  • Caches resolved lookup names, SQL names, and index handles to avoid repeated resolution and unnecessary allocations.
  • Adds diagnostics, documentation, CI coverage, and focused integration tests.

API and ABI breaking changes

No changes to host, it uses the existing RawSubmoduleV10 for accessor namespaces and the existing ExplicitNames namespace mappings for canonical names.

On .NET 10, contexts move from generated module types into Runtime, changing their assembly identity. Existing standalone .NET 8 modules retain generated contexts.

Rollback safety impact

n/a

Expected complexity level and risk

4/5. This PR touches a lot of systems: source generation, runtime registration, NativeAOT publication, schema composition, function dispatch, client generation, subscriptions, ... possibly more.

The main risks are incorrect assembly ownership or dispatch ordering, cross-namespace lookup mistakes, NativeAOT export/trimming behavior, and regressions in existing flat modules.

Testing

  • .NET 8 and .NET 10 generator/Verify suites; regenerated snapshots.
  • Rust codegen tests, including C# bindings generated from a TypeScript submodule.
  • NativeAOT publication, root export selection, and cross-library helper/HTTP integration.
  • Namespace client integration: subscriptions, callbacks, indexes, views, events, private tables, one-off queries, and unsubscribe cleanup.
  • Namespaced scheduled reducers/procedures and cross-namespace transaction commit/rollback.
  • Root-defined RLS targeting namespaced tables and environment-security integration.
  • Distinct accessor/canonical names (MyAuth → auth_data) and default namespace case conversion (MyAuth → my_auth).
  • Full C# SDK unit-test suite.

@lisandroct
lisandroct marked this pull request as draft September 23, 2026 17:07
@lisandroct
lisandroct force-pushed the lisandro/csharp-submodules branch 2 times, most recently from 7ee3c50 to ab24ef3 Compare September 28, 2026 14:05
@lisandroct
lisandroct marked this pull request as ready for review September 28, 2026 15:18
@lisandroct
lisandroct force-pushed the lisandro/csharp-submodules branch from ab24ef3 to 03252b0 Compare September 30, 2026 20:35
@lisandroct
lisandroct force-pushed the lisandro/csharp-submodules branch from 03252b0 to 3d1b967 Compare October 1, 2026 14:32

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant