GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — C# nested submodules (#6112) · clockworklabs/SpacetimeDB@06b6390

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • TESTING.md
  • crates
    • bench
      • README.md
      • examples
        • csharp_artifact.rs
    • bindings-csharp
      • BSATN.Codegen
        • Type.cs
      • BSATN.Runtime
        • QueryBuilder.cs
      • Codegen.Tests
        • Tests.cs
        • fixtures
          • client/snapshots
            • Type#CustomClass.verified.cs
            • Type#CustomStruct.verified.cs
            • Type#PublicTable.verified.cs
          • diag/snapshots
            • ExtraCompilationErrors.net10.verified.txt
            • Module#FFI.verified.cs
            • Module#InAnotherNamespace.TestDuplicateTableName.verified.cs
            • Module#Player.verified.cs
            • Module#TestAutoIncNotInteger.verified.cs
            • Module#TestDefaultFieldValues.verified.cs
            • Module#TestDuplicateTableName.verified.cs
            • Module#TestIndexIssues.verified.cs
            • Module#TestScheduleIssues.verified.cs
            • Module#TestUniqueNotEquatable.verified.cs
            • Module.net10#FFI.verified.cs
            • Module.net10#InAnotherNamespace.TestDuplicateTableName.verified.cs
            • Module.net10#Player.verified.cs
            • Module.net10#Reducers.InAnotherNamespace.TestDuplicateReducerName.verified.cs
            • Module.net10#Reducers.OnReducerWithReservedPrefix.verified.cs
            • Module.net10#Reducers.TestDuplicateReducerKind1.verified.cs
            • Module.net10#Reducers.TestDuplicateReducerKind2.verified.cs
            • Module.net10#Reducers.TestDuplicateReducerName.verified.cs
            • Module.net10#Reducers.TestReducerReturnType.verified.cs
            • Module.net10#Reducers.TestReducerWithoutContext.verified.cs
            • Module.net10#Reducers.__ReducerWithReservedPrefix.verified.cs
            • Module.net10#TestAutoIncNotInteger.verified.cs
            • Module.net10#TestDefaultFieldValues.verified.cs
            • Module.net10#TestDuplicateTableName.verified.cs
            • Module.net10#TestIndexIssues.verified.cs
            • Module.net10#TestScheduleIssues.DummyScheduledReducer.verified.cs
            • Module.net10#TestScheduleIssues.verified.cs
            • Module.net10#TestUniqueNotEquatable.verified.cs
            • Type#MyStruct.verified.cs
            • Type#NonEquatableViewPrimaryKey.verified.cs
            • Type#NonEquatableViewPrimaryKeyRow.verified.cs
            • Type#TestTypeParams_T_.verified.cs
            • Type#TestUnsupportedType.verified.cs
            • Type#ViewPrimaryKeyPartialRow.verified.cs
            • Type#ViewPrimaryKeyRenamedRow.verified.cs
          • explicitnames/snapshots
            • Module#DemoTable.verified.cs
            • Module#FFI.verified.cs
            • Module.net10#DemoTable.verified.cs
            • Module.net10#FFI.verified.cs
            • Module.net10#Reducers.DemoProcedure.verified.cs
            • Module.net10#Reducers.DemoReducer.verified.cs
            • Type#DemoType.verified.cs
          • server/snapshots
            • Module#BTreeMultiColumn.verified.cs
            • Module#BTreeViews.verified.cs
            • Module#FFI.verified.cs
            • Module#MultiTableRow.verified.cs
            • Module#PrivateTable.verified.cs
            • Module#PublicTable.verified.cs
            • Module#RegressionMultipleUniqueIndexesHadSameName.verified.cs
            • Module#Timers.SendMessageTimer.verified.cs
            • Module.net10#BTreeMultiColumn.verified.cs
            • Module.net10#BTreeViews.verified.cs
            • Module.net10#FFI.verified.cs
            • Module.net10#MultiTableRow.InsertMultiData.verified.cs
            • Module.net10#MultiTableRow.verified.cs
            • Module.net10#PrivateTable.verified.cs
            • Module.net10#PublicTable.verified.cs
            • Module.net10#Reducers.InsertData.verified.cs
            • Module.net10#Reducers.ScheduleImmediate.verified.cs
            • Module.net10#RegressionMultipleUniqueIndexesHadSameName.verified.cs
            • Module.net10#Test.NestingNamespaces.AndClasses.InsertData2.verified.cs
            • Module.net10#Timers.Init.verified.cs
            • Module.net10#Timers.SendMessageTimer.verified.cs
            • Module.net10#Timers.SendScheduledMessage.verified.cs
            • Type#ContainsNestedLists.verified.cs
            • Type#CustomClass.verified.cs
            • Type#CustomNestedClass.verified.cs
            • Type#CustomRecord.verified.cs
            • Type#CustomStruct.verified.cs
            • Type#EmptyClass.verified.cs
            • Type#EmptyRecord.verified.cs
            • Type#EmptyStruct.verified.cs
            • Type#FormerlyForbiddenFieldNames.verified.cs
      • Codegen
        • Diag.cs
        • ImmediateSchedule.cs
        • Module.cs
        • ModuleComposition.cs
        • NamespaceDeclaration.cs
      • README.md
      • Runtime
        • HandlerContext.cs
        • Internal
          • IIndex.cs
          • IModuleContext.cs
          • ITable.cs
          • Module.cs
          • NamespaceBinding.cs
          • NamespaceRegistry.cs
          • TableHandle.cs
        • ModuleContexts.cs
        • ProcedureContext.cs
    • codegen/src
      • csharp.rs
    • testing/tests
      • standalone_integration_test.rs
  • docs/docs/00200-core-concepts/00100-databases
    • 00600-submodules.md
  • modules/nested-namespace-test-cs
    • Directory.Build.props
    • Lib.cs
    • README.md
    • libraries
      • Branch
        • Branch.csproj
        • Lib.cs
      • Leaf
        • Leaf.csproj
        • Lib.cs
      • Outer
        • Lib.cs
        • Outer.csproj
      • Public
        • Lib.cs
        • Public.csproj
    • nested-namespace-test-cs.csproj
  • sdks/csharp
    • DEVELOP.md
    • examples~/regression-tests/nested-namespaces
      • Program.cs
      • README.md
      • client.csproj
      • module_bindings
        • Branch
          • Leaf
            • Namespace.g.cs
            • Procedures
              • Instance.g.cs
              • Next.g.cs
            • Reducers
              • Ping.g.cs
              • Pong.g.cs
            • Tables
              • Anonymous.g.cs
              • Current.g.cs
              • QueryAnonymous.g.cs
              • QueryCurrent.g.cs
              • RefUser.g.cs
              • User.g.cs
            • Types
              • RefUser.g.cs
              • User.g.cs
          • Namespace.g.cs
          • Procedures
            • Instance.g.cs
          • Tables
            • QueryChild.g.cs
          • Types
            • User.g.cs
        • Leaf
          • Namespace.g.cs
          • Procedures
            • Instance.g.cs
            • Next.g.cs
          • Reducers
            • Ping.g.cs
            • Pong.g.cs
          • Tables
            • Anonymous.g.cs
            • Current.g.cs
            • QueryAnonymous.g.cs
            • QueryCurrent.g.cs
            • RefUser.g.cs
            • User.g.cs
          • Types
            • RefUser.g.cs
            • User.g.cs
        • Procedures
          • Instance.g.cs
        • Promoted
          • Namespace.g.cs
          • Procedures
            • Instance.g.cs
            • Next.g.cs
          • Reducers
            • Ping.g.cs
            • Pong.g.cs
          • Tables
            • Anonymous.g.cs
            • Current.g.cs
            • QueryAnonymous.g.cs
            • QueryCurrent.g.cs
            • RefUser.g.cs
            • User.g.cs
          • Types
            • RefUser.g.cs
            • User.g.cs
        • Reducers
          • CheckTables.g.cs
          • Ping.g.cs
        • SecondLeaf
          • Namespace.g.cs
          • Procedures
            • Instance.g.cs
            • Next.g.cs
          • Reducers
            • Ping.g.cs
            • Pong.g.cs
          • Tables
            • Anonymous.g.cs
            • Current.g.cs
            • QueryAnonymous.g.cs
            • QueryCurrent.g.cs
            • RefUser.g.cs
            • User.g.cs
          • Types
            • RefUser.g.cs
            • User.g.cs
        • SpacetimeDBClient.g.cs
        • Tables
          • Deep.g.cs
          • Nested.g.cs
          • QueryDeep.g.cs
          • QueryPublic.g.cs
          • User.g.cs
        • Types
          • NestedResult.g.cs
          • RefUser.g.cs
          • User.g.cs
        • class
          • Branch
            • Leaf
              • Namespace.g.cs
              • Procedures
                • Instance.g.cs
                • Next.g.cs
              • Reducers
                • Ping.g.cs
                • Pong.g.cs
              • Tables
                • Anonymous.g.cs
                • Current.g.cs
                • QueryAnonymous.g.cs
                • QueryCurrent.g.cs
                • RefUser.g.cs
                • User.g.cs
              • Types
                • RefUser.g.cs
                • User.g.cs
            • Namespace.g.cs
            • Procedures
              • Instance.g.cs
            • Tables
              • QueryChild.g.cs
            • Types
              • User.g.cs
          • Namespace.g.cs
          • Procedures
            • Instance.g.cs
            • Next.g.cs
          • Reducers
            • Ping.g.cs
            • Pong.g.cs
          • Tables
            • Anonymous.g.cs
            • Current.g.cs
            • QueryAnonymous.g.cs
            • QueryCurrent.g.cs
            • RefUser.g.cs
            • User.g.cs
          • Types
            • RefUser.g.cs
            • User.g.cs
    • tests~
      • QueryBuilderTests.cs
    • tools~
      • gen-regression-tests.sh
      • run-regression-tests.sh

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎TESTING.md‎

Copy file name to clipboardExpand all lines: TESTING.md
+18Lines changed: 18 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ The namespace tests are integration tests, plus focused generator diagnostics:
107107
- `cargo test -p spacetimedb-testing --test standalone_integration_test namespace_csharp`:
108108
independent dependency publication, root export selection, and cross-namespace
109109
helper/HTTP calls, and runtime name conversion compared with host validation.
110+
The nested fixture additionally checks repeated assembly instances, public
111+
child promotion, deep writable/read-only access, per-instance dispatch and
112+
transactions, and HTTP warnings at publication before any function calls.
110113
- `cargo test -p spacetimedb-testing --test environment namespace_csharp_environment_security`:
111114
root/public environment access, denial of namespaced host calls, and default
112115
namespace case conversion when `Name` is omitted.
@@ -119,11 +122,26 @@ The namespace tests are integration tests, plus focused generator diagnostics:
119122
`Accessor = "MyAuth", Name = "auth_data"`. The existing
120123
`sdks/csharp/tools~/run-regression-tests.sh 8 10` harness includes it in the
121124
.NET 10 module pass while retaining .NET 8 regressions.
125+
- The [nested client regression](sdks/csharp/examples~/regression-tests/nested-namespaces/README.md)
126+
is included in the same harness. It runs C# 9 bindings on both .NET 8 and
127+
.NET 10 against the .NET 10 nested module, including three-level canonical SQL,
128+
independent caches, reducer/procedure results and errors, views, joins, and
129+
unsubscribe cleanup.
122130

123131
Use the local package setup in [DEVELOP.md](sdks/csharp/DEVELOP.md), not stale
124132
published NuGet packages, when exercising changed query/runtime code.
125133
Library-defined RLS inside named namespaces and cross-language module composition
126134
are unsupported, not integration cases awaiting a passing assertion.
135+
The nested host fixture also executes instance-aware module query views, including
136+
deep paths, filters, and both semijoin directions. Immediate reducer/procedure
137+
scheduling targets repeated instances through selected contexts and uses their
138+
canonical paths. Context-selection assertions in the same fixture cover all
139+
context families, shared state, and cross-scope transaction rollback. See the
140+
[module limitations](crates/bindings-csharp/README.md#nested-assemblies).
141+
142+
For module performance comparisons, use the
143+
[prebuilt-artifact benchmark](crates/bench/README.md#comparing-c-artifacts).
144+
The circles integration test is a correctness smoke test, not a throughput result.
127145

128146
## Schema parity tests
129147

Collapse file

‎crates/bench/README.md‎

Copy file name to clipboardExpand all lines: crates/bench/README.md
+23-1Lines changed: 23 additions & 1 deletion
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,28 @@ cargo test --release --package spacetimedb-testing --test standalone_integration
115115
cargo test --release --package spacetimedb-testing --test standalone_integration_test test_calling_bench_db_circles -- --exact --nocapture
116116
```
117117

118+
## Comparing C# artifacts
119+
120+
The `csharp_artifact` example accepts an already-built `benchmarks-cs` WASM module.
121+
It measures empty reducer dispatch, a 10,000-row string-table scan, and the existing
122+
circles cross-join workload (`initial_load = 100`). It uses the
123+
same in-process host and excludes compilation and publication from measurements.
124+
125+
Build each revision with the same .NET SDK, NativeAOT toolchain, and release CLI
126+
settings in separate worktrees. Use the optimized `StdbModule.opt.wasm` artifacts
127+
from the `native` output directory. Build the runner once, then run it directly:
128+
129+
```sh
130+
cargo build --release -p spacetimedb-bench --example csharp_artifact
131+
CSHARP_BENCH_WASM=/absolute/path/to/before.wasm target/release/examples/csharp_artifact --bench --save-baseline before
132+
CSHARP_BENCH_WASM=/absolute/path/to/after.wasm target/release/examples/csharp_artifact --bench --baseline before
133+
```
134+
135+
Defaults are 30 samples, 3 seconds warmup, and 20 seconds measurement per workload.
136+
Criterion options can override these. Do not run builds or other tests during
137+
measurement; repeat in reverse order before attributing a small change to code.
138+
This checks existing flat modules, not nested-instance startup cost or memory use.
139+
118140
## Pretty report
119141
To generate a nicely formatted markdown report, you can use the "summarize" binary.
120142
This is used on CI (see [`../../.github/workflows/benchmarks.yml`](../../.github/workflows/benchmarks.yml)).
@@ -220,4 +242,4 @@ You can generate flamegraphs using `flamegraph.sh` script:
220242
```bash
221243
# ./flamegraph.sh BENCH_EXECUTABLE FILTER SVG_PATH
222244
./flamegraph.sh generic stdb_raw/mem/insert_bulk/location/multi_index/load=0/count=100 result.svg"
223-
```
245+
```
Collapse file

‎crates/bench/examples/csharp_artifact.rs‎

Copy file name to clipboard
+53Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//! Compare prebuilt C# benchmark modules without rebuilding or changing the host.
2+
use criterion::{async_executor::AsyncExecutor, Criterion};
3+
use spacetimedb_bench::{
4+
database::BenchDatabase,
5+
schemas::{create_sequential, u32_u64_str, IndexStrategy},
6+
spacetime_module::SpacetimeModule,
7+
};
8+
use spacetimedb_lib::sats::product;
9+
use spacetimedb_testing::modules::{CompiledModule, ModuleLanguage};
10+
use std::{path::PathBuf, sync::OnceLock, time::Duration};
11+
12+
struct Artifact;
13+
14+
impl ModuleLanguage for Artifact {
15+
const NAME: &'static str = "csharp-artifact";
16+
17+
fn get_module() -> &'static CompiledModule {
18+
static MODULE: OnceLock<CompiledModule> = OnceLock::new();
19+
MODULE.get_or_init(|| {
20+
let path = PathBuf::from(std::env::var_os("CSHARP_BENCH_WASM").expect("set CSHARP_BENCH_WASM"));
21+
CompiledModule::from_artifact("benchmarks-cs", spacetimedb::messages::control_db::HostType::Wasm, path)
22+
})
23+
}
24+
}
25+
26+
fn main() {
27+
let mut criterion = Criterion::default()
28+
.sample_size(30)
29+
.warm_up_time(Duration::from_secs(3))
30+
.measurement_time(Duration::from_secs(20))
31+
.configure_from_args();
32+
let mut db = SpacetimeModule::<Artifact>::build(true).unwrap();
33+
let table = db.create_table::<u32_u64_str>(IndexStrategy::Unique0).unwrap();
34+
db.insert_bulk(&table, create_sequential::<u32_u64_str>(0xdeadbeef, 10_000, 100))
35+
.unwrap();
36+
criterion.bench_function("csharp-artifact/empty", |b| b.iter(|| db.empty_transaction().unwrap()));
37+
criterion.bench_function("csharp-artifact/scan-10000", |b| b.iter(|| db.iterate(&table).unwrap()));
38+
(&db).block_on(async {
39+
db.module
40+
.call_reducer_binary("init_game_circles", &product![100u32])
41+
.await
42+
.unwrap();
43+
});
44+
criterion.bench_function("csharp-artifact/circles-100", |b| {
45+
b.to_async(&db).iter(|| async {
46+
db.module
47+
.call_reducer_binary("run_game_circles", &product![100u32])
48+
.await
49+
.unwrap()
50+
});
51+
});
52+
criterion.final_summary();
53+
}
Collapse file

‎crates/bindings-csharp/BSATN.Codegen/Type.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/BSATN.Codegen/Type.cs
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,9 @@ public override string ToString() =>
694694

695695
extensions.Contents.Append(
696696
$$"""
697+
#if NET10_0_OR_GREATER
698+
[System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)]
699+
#endif
697700
public void ReadFields(System.IO.BinaryReader reader) {
698701
{{string.Join(
699702
"\n",
Collapse file

‎crates/bindings-csharp/BSATN.Runtime/QueryBuilder.cs‎

Copy file name to clipboardExpand all lines: crates/bindings-csharp/BSATN.Runtime/QueryBuilder.cs
+21-3Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,47 @@ namespace SpacetimeDB;
22

33
using System;
44
using System.Globalization;
5+
using System.Linq;
56

6-
/// <summary>A table identifier with a separately quoted optional namespace and local name.</summary>
7+
/// <summary>A table identifier with separately quoted namespace segments and local name.</summary>
78
public readonly struct SqlTableName
89
{
10+
private readonly string? quotedNamespace;
11+
12+
/// <summary>The namespace path, without SQL quoting.</summary>
913
public string? Namespace { get; }
1014
public string LocalName { get; }
1115

1216
public SqlTableName(string localName)
1317
{
1418
LocalName = localName;
1519
Namespace = null;
20+
quotedNamespace = null;
1621
}
1722

1823
public SqlTableName(string @namespace, string localName)
1924
{
2025
Namespace = @namespace ?? throw new ArgumentNullException(nameof(@namespace));
2126
LocalName = localName;
27+
quotedNamespace = SqlFormat.QuoteIdent(@namespace);
28+
}
29+
30+
public SqlTableName(string[] namespaceSegments, string localName)
31+
{
32+
namespaceSegments =
33+
namespaceSegments ?? throw new ArgumentNullException(nameof(namespaceSegments));
34+
Namespace = namespaceSegments.Length == 0 ? null : string.Join(".", namespaceSegments);
35+
LocalName = localName;
36+
quotedNamespace =
37+
namespaceSegments.Length == 0
38+
? null
39+
: string.Join(".", namespaceSegments.Select(SqlFormat.QuoteIdent));
2240
}
2341

2442
public override string ToString() =>
25-
Namespace is null
43+
quotedNamespace is null
2644
? SqlFormat.QuoteIdent(LocalName)
27-
: SqlFormat.QuoteIdent(Namespace) + "." + SqlFormat.QuoteIdent(LocalName);
45+
: quotedNamespace + "." + SqlFormat.QuoteIdent(LocalName);
2846
}
2947

3048
public readonly struct SqlLiteral<T>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.