mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-12 10:48:19 -04:00
6f91cfd524
# Description of Changes This PR adds a regression test covering nullable reference-type view returns in C# modules (e.g. Account? where Account is a class), as reported in [#3962](https://github.com/clockworklabs/SpacetimeDB/issues/3962). ```csharp public static Account? MyAccount(ViewContext ctx) ``` * Updated the C# regression-test server module to include a reference-type table and views that exercise the RefOption path: * A new public reference-type table row: ```csharp [SpacetimeDB.Table(Name = "account", Public = true)] public partial class Account { ... } ``` * A public at-most-one view that returns a nullable reference type (Account?) via Find(...): ```csharp [SpacetimeDB.View(Name = "my_account", Public = true)] public static Account? MyAccount(ViewContext ctx) { return ctx.Db.account.Identity.Find(ctx.Sender) as Account; } ``` * A second public view that returns null to ensure the “empty result” case is exercised: ```csharp [SpacetimeDB.View(Name = "my_account_missing", Public = true)] public static Account? MyAccountMissing(ViewContext ctx) => null; ``` * Updated ClientConnected to ensure an Account row exists for the connecting identity so the “one row” case is deterministic. * Updated the C# regression-test client to: * Subscribe to the new views: * `SELECT * FROM my_account` * `SELECT * FROM my_account_missing` * Assert correct semantics for nullable reference-type view returns: * MyAccount.Count == 1 * MyAccountMissing.Count == 0 * Updated the regression-test server project to use local C# runtime/codegen project references so the regression module exercises the in-repo generator/runtime behavior (instead of the published SpacetimeDB.Runtime package). # API and ABI breaking changes None. * No changes to public module schema/wire format semantics beyond adding regression-test-only tables/views. * No behavior changes outside the C# regression test module + harness. # Expected complexity level and risk 2 - Low * Changes are isolated to regression tests and project wiring. * The scenario specifically guards the nullable reference-type “Option-like view return” path against regressions. # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [X] Ran C# regression tests with no failures in new View tests Signed-off-by: Ryan <r.ekhoff@clockworklabs.io>
SpacetimeDB C# SDK
Overview
This repository contains the C# and Unity client SDKs for SpacetimeDB. These SDKs contain all the tools you need to build native clients for SpacetimeDB modules using C#.
Documentation
The Unity SDK uses the same code as the C# SDK. You can find the documentation for the C# SDK in the C# SDK Reference. For a guided tutorial, see the C# SDK Quickstart.
There is also a comprehensive Unity tutorial/demo available:
- Unity Tutorial Doc
- Unity Demo Repo
Internal developer documentation
See DEVELOP.md.