Skip to content

Commit

Permalink
Migrate C# client-side reducer enum to the new syntax
Browse files Browse the repository at this point in the history
As per clockworklabs/SpacetimeDBPrivate#1198.

This makes reducers use the same codegen structure as tables and other tuple types, but nests them inside a `Reducer` class as subclasses for pattern-matching, like we allow on tagged enums.

The reason we don't use a tagged enum here anymore is because we don't need BSATN sum type support for the Reducer enum, and it imposes unnecessary restrictions like max 256 elements.
  • Loading branch information
RReverser committed Dec 3, 2024
1 parent 03cf2f4 commit cbe8de0
Show file tree
Hide file tree
Showing 8 changed files with 314 additions and 368 deletions.
41 changes: 9 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,49 +120,26 @@ jobs:
run: |
sudo mkdir /stdb
sudo chmod 777 /stdb
- name: Checkout C# SDK
uses: actions/checkout@v4
with:
repository: clockworklabs/spacetimedb-csharp-sdk
ref: staging
path: spacetimedb-csharp-sdk

- name: C# SDK tests
- name: Setup NuGet override for C# SDK
working-directory: spacetimedb-csharp-sdk
run: |
( cd crates/bindings-csharp/BSATN.Runtime && dotnet pack )
cd spacetimedb-csharp-sdk
# Write out the nuget config file to `nuget.config`. This causes the spacetimedb-csharp-sdk repository
# to be aware of the local versions of the `bindings-csharp` packages in SpacetimeDB, and use them if
# available. Otherwise, `spacetimedb-csharp-sdk` will use the NuGet versions of the packages.
# This means that (if version numbers match) we will test the local versions of the C# packages, even
# if they're not pushed to NuGet.
# See https://learn.microsoft.com/en-us/nuget/reference/nuget-config-file for more info on the config file,
# and https://tldp.org/LDP/abs/html/here-docs.html for more info on this bash feature.
cat >nuget.config <<EOF
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!-- Local NuGet repositories -->
<add key="Local SpacetimeDB.BSATN.Runtime" value="../crates/bindings-csharp/BSATN.Runtime/bin/Release" />
</packageSources>
<packageSourceMapping>
<!-- Ensure that SpacetimeDB.BSATN.Runtime is used from the local folder. -->
<!-- Otherwise we risk an outdated version being quietly pulled from NuGet for testing. -->
<packageSource key="Local SpacetimeDB.BSATN.Runtime">
<package pattern="SpacetimeDB.BSATN.Runtime" />
</packageSource>
<!-- Fallback to NuGet for other packages. -->
<packageSource key="nuget.org">
<package pattern="*" />
</packageSource>
</packageSourceMapping>
</configuration>
EOF
dotnet pack ../crates/bindings-csharp/BSATN.Runtime
./tools~/write-nuget-config.sh ..
# clear package caches, so we get fresh ones even if version numbers haven't changed
dotnet nuget locals all --clear
dotnet test
- name: Run C# SDK tests
working-directory: spacetimedb-csharp-sdk
run: dotnet test

lints:
name: Lints
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit cbe8de0

Please sign in to comment.