Skip to content

C# submodules - #5974

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

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 from 050b6d9 to fa97ddc Compare September 25, 2026 18:52

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant