Conversation
Bound struct out of SpacetimeDB.Internal to SpacetimeDB and Local out of SpacetiemDB.Runtime
JasonAtClockwork
approved these changes
Jan 14, 2026
Contributor
JasonAtClockwork
left a comment
There was a problem hiding this comment.
LGTM - the extra tests are a solid add.
cloutiertyler
pushed a commit
that referenced
this pull request
Jan 16, 2026
…d `Local` out of `SpacetiemDB.Runtime` (#3996) # Description of Changes This PR fixes a C# SDK regression where using `Bound` in index filters could trigger an ambiguous reference compiler error for Local after upgrading to `v1.11.2`, as reported in [#3995](#3995). It also fixes a related warning-spam regression (`CS0436`) where user projects could see `Local` type conflicts between generated module code and the `SpacetimeDB.Runtime` assembly. * Introduced a public `SpacetimeDB.Bound` type so users no longer need to import `SpacetimeDB.Internal` to use bounds in index filters. * Kept `SpacetimeDB.Internal.Bound` for compatibility, but added implicit conversions between `SpacetimeDB.Internal.Bound` and `SpacetimeDB.Bound`. * Updated the C# code generator to emit fully-qualified `global::SpacetimeDB.Bound` in generated index filter signatures, avoiding `SpacetimeDB.Internal` in public-facing APIs and preventing name collisions (e.g., `Local`). * Updated internal runtime bounds helpers (`BTreeIndexBounds<...>`) to explicitly use `SpacetimeDB.Bound` when constructing range-scan arguments. * Updated Codegen snapshot fixtures to match the new generated output (type name + formatting). * Fixed codegen output for `ITableView` `static abstract` member implementations to generate `public static` methods (required for the generated code to compile). It also fixes a related warning-spam regression (CS0436) where user projects could see Local type conflicts between generated module code and the SpacetimeDB.Runtime assembly. Additional fix (related to the `Local` reports): * Removed the runtime assembly’s ownership of `SpacetimeDB.Local` (introduced more recently than the generated module `Local`) to prevent `CS0436` duplicate-type warnings. Basically, the runtime’s concrete `Local`/`ProcedureTxContext` helpers were renamed and made internal so the code generator remains the sole owner of module-level `SpacetimeDB.Local`. Regression coverage: * Added generator regression assertions to ensure generated code does not reference `global::SpacetimeDB.Internal.Bound<...>` and does reference `global::SpacetimeDB.Bound<...>`. * Added a runtime API regression assertion that `SpacetimeDB.Bound` exists and is public in the runtime reference. * Added a regression assertion that `SpacetimeDB.Runtime` does not define codegen-owned types (e.g. `SpacetimeDB.Local`, `ProcedureContext`, etc.) to prevent future `CS0436` conflicts. * Added a “simulated downstream user file” compile check ensuring no `CS0436` diagnostics occur when user code references `SpacetimeDB.Local`. # API and ABI breaking changes None. * No schema or wire-format changes. * The changes are limited to C# type exposure / naming and codegen output. * `SpacetimeDB.Internal.Bound` remains usable via implicit conversions (backwards compatible for existing code). # Expected complexity level and risk 2 - Low * Changes are isolated to C# runtime type exposure, codegen type references, and snapshot updates. * No runtime behavior changes to index scan encoding/decoding; only avoids requiring SpacetimeDB.Internal in user code. # Testing - [X] Ran:`dotnet test crates/bindings-csharp/Codegen.Tests/Codegen.Tests.csproj` - [X] Ran regression tests locally.
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.
Description of Changes
This PR fixes a C# SDK regression where using
Boundin index filters could trigger an ambiguous reference compiler error for Local after upgrading tov1.11.2, as reported in #3995.It also fixes a related warning-spam regression (
CS0436) where user projects could seeLocaltype conflicts between generated module code and theSpacetimeDB.Runtimeassembly.SpacetimeDB.Boundtype so users no longer need to importSpacetimeDB.Internalto use bounds in index filters.SpacetimeDB.Internal.Boundfor compatibility, but added implicit conversions betweenSpacetimeDB.Internal.BoundandSpacetimeDB.Bound.global::SpacetimeDB.Boundin generated index filter signatures, avoidingSpacetimeDB.Internalin public-facing APIs and preventing name collisions (e.g.,Local).BTreeIndexBounds<...>) to explicitly useSpacetimeDB.Boundwhen constructing range-scan arguments.ITableViewstatic abstractmember implementations to generatepublic staticmethods (required for the generated code to compile).It also fixes a related warning-spam regression (CS0436) where user projects could see Local type conflicts between generated module code and the SpacetimeDB.Runtime assembly.
Additional fix (related to the
Localreports):SpacetimeDB.Local(introduced more recently than the generated moduleLocal) to preventCS0436duplicate-type warnings. Basically, the runtime’s concreteLocal/ProcedureTxContexthelpers were renamed and made internal so the code generator remains the sole owner of module-levelSpacetimeDB.Local.Regression coverage:
global::SpacetimeDB.Internal.Bound<...>and does referenceglobal::SpacetimeDB.Bound<...>.SpacetimeDB.Boundexists and is public in the runtime reference.SpacetimeDB.Runtimedoes not define codegen-owned types (e.g.SpacetimeDB.Local,ProcedureContext, etc.) to prevent futureCS0436conflicts.CS0436diagnostics occur when user code referencesSpacetimeDB.Local.API and ABI breaking changes
None.
SpacetimeDB.Internal.Boundremains usable via implicit conversions (backwards compatible for existing code).Expected complexity level and risk
2 - Low
Testing
dotnet test crates/bindings-csharp/Codegen.Tests/Codegen.Tests.csproj