diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e0de3213dbb..873613afe19 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -113,62 +113,6 @@ jobs: working-directory: crates/bindings-csharp run: dotnet test -warnaserror - sdk_test: - name: SDK Tests - runs-on: spacetimedb-runner - steps: - - name: Find Git ref - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - PR_NUMBER="${{ github.event.inputs.pr_number || null }}" - if test -n "${PR_NUMBER}"; then - GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )" - else - GIT_REF="${{ github.ref }}" - fi - echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV" - - - name: Checkout sources - uses: actions/checkout@v4 - with: - ref: ${{ env.GIT_REF }} - - - uses: dsherret/rust-toolchain-file@v1 - - - uses: actions/setup-dotnet@v3 - with: - global-json-file: modules/global.json - - - name: Create /stdb dir - run: | - sudo mkdir /stdb - sudo chmod 777 /stdb - - - name: Checkout C# SDK - uses: actions/checkout@v4 - with: - repository: clockworklabs/spacetimedb-csharp-sdk - ref: master - path: spacetimedb-csharp-sdk - - - name: Setup NuGet override for C# SDK - working-directory: spacetimedb-csharp-sdk - run: | - dotnet pack ../crates/bindings-csharp/BSATN.Runtime - # The SDK package overrides the following crate for use in their tests. - # Even though it doesn't actually depend on it, we still need to pack it - # so dotnet doesn't complain. - dotnet pack ../crates/bindings-csharp/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 - - - name: Run C# SDK tests - working-directory: spacetimedb-csharp-sdk - run: dotnet test - lints: name: Lints runs-on: spacetimedb-runner diff --git a/sdks/csharp/.github/workflows/test.yml b/.github/workflows/csharp-test.yml similarity index 57% rename from sdks/csharp/.github/workflows/test.yml rename to .github/workflows/csharp-test.yml index ef92098c090..befeefe728c 100644 --- a/sdks/csharp/.github/workflows/test.yml +++ b/.github/workflows/csharp-test.yml @@ -1,9 +1,9 @@ -name: Test Suite +name: C#/Unity - Test Suite on: push: branches: - - staging + - master pull_request: jobs: @@ -12,56 +12,18 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - with: - submodules: true - - # Grab the SpacetimeDB branch name from the PR description. If it's not found, master will be used instead. - # We'll use this branch name for any integration tests with SpacetimeDB. - - - name: Extract SpacetimeDB branch name or PR link from PR description - id: extract-branch - if: github.event_name == 'pull_request' - env: - description: ${{ github.event.pull_request.body }} - run: | - # Check if description contains a branch name or a PR link - branch_or_pr=$(echo "$description" | grep -oP '(?<=SpacetimeDB branch name:\s).+') - echo "Branch or PR found: $branch_or_pr" - - if [[ -z "$branch_or_pr" ]]; then - branch="master" - elif [[ "$branch_or_pr" =~ ^https://github.com/.*/pull/[0-9]+$ ]]; then - # If it's a PR link, extract the branch name from the PR - pr_number=$(echo "$branch_or_pr" | grep -oP '[0-9]+$') - branch=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - https://api.github.com/repos/clockworklabs/SpacetimeDB/pulls/$pr_number | jq -r '.head.ref') - else - # It's already a branch name - branch="$branch_or_pr" - fi - - echo "branch=$branch" >> $GITHUB_OUTPUT - echo "Final branch name: $branch" - - - name: Checkout SpacetimeDB - uses: actions/checkout@v4 - id: checkout-stdb - with: - repository: clockworklabs/SpacetimeDB - ref: ${{ steps.extract-branch.outputs.branch }} - path: SpacetimeDB~ # Run cheap .NET tests first. If those fail, no need to run expensive Unity tests. - name: Setup dotnet uses: actions/setup-dotnet@v3 with: - global-json-file: SpacetimeDB~/modules/global.json + global-json-file: modules/global.json - name: Override NuGet packages run: | - dotnet pack SpacetimeDB~/crates/bindings-csharp/BSATN.Runtime - dotnet pack SpacetimeDB~/crates/bindings-csharp/Runtime + dotnet pack crates/bindings-csharp/BSATN.Runtime + dotnet pack crates/bindings-csharp/Runtime # 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 @@ -69,31 +31,33 @@ jobs: # 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. - ./tools~/write-nuget-config.sh SpacetimeDB~ + cd sdks/csharp + ./tools~/write-nuget-config.sh ../.. - name: Run .NET tests + working-directory: sdks/csharp run: dotnet test -warnaserror - name: Verify C# formatting + working-directory: sdks/csharp run: dotnet format --no-restore --verify-no-changes SpacetimeDB.ClientSDK.sln # Now, setup the Unity tests. - name: Patch spacetimedb dependency in Cargo.toml - working-directory: unity-tests~/server-rust + working-directory: demo/Blackholio/server-rust run: | - sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../SpacetimeDB~/crates/bindings\" \}|" Cargo.toml + sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../../crates/bindings\" \}|" Cargo.toml cat Cargo.toml - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - - name: Cache Rust dependencies uses: Swatinem/rust-cache@v2 id: cache-rust-deps with: - workspaces: unity-tests~/server-rust + workspaces: demo/Blackholio/server-rust key: ${{ steps.checkout-stdb.outputs.commit }} # Cache Rust deps even if unit tests have failed. cache-on-failure: true @@ -104,21 +68,25 @@ jobs: # Rebuild only if we didn't get a precise cache hit. if: steps.cache-rust-deps.outputs.cache-hit == 'false' run: | - cargo install --force --path SpacetimeDB~/crates/cli --locked --message-format=short - cargo install --force --path SpacetimeDB~/crates/standalone --locked --message-format=short + cargo install --force --path crates/cli --locked --message-format=short + cargo install --force --path crates/standalone --locked --message-format=short # Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules). ln -sf $HOME/.cargo/bin/spacetimedb-cli $HOME/.cargo/bin/spacetime env: # Share the target directory with our local project to avoid rebuilding same SpacetimeDB crates twice. - CARGO_TARGET_DIR: unity-tests~/server-rust/target + CARGO_TARGET_DIR: demo/Blackholio/server-rust/target - name: Generate client bindings - working-directory: unity-tests~/server-rust + working-directory: demo/Blackholio/server-rust run: bash ./generate.sh -y - name: Check for changes run: | - git diff --exit-code unity-tests~/client-unity/Assets/Scripts/autogen || { + # This was copied from tools/check-diff.sh. + # It's required because `spacetime generate` creates lines with the SpacetimeDB commit + # version, which would make this `git diff` check very brittle if included. + PATTERN='^// This was generated using spacetimedb cli version.*' + git diff --exit-code --ignore-matching-lines="$PATTERN" -- demo/Blackholio/client-unity/Assets/Scripts/autogen || { echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch." exit 1 } @@ -127,6 +95,7 @@ jobs: uses: DeNA/unity-meta-check@v3 with: enable_pr_comment: ${{ github.event_name == 'pull_request' }} + target_path: sdks/csharp env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" @@ -136,25 +105,26 @@ jobs: disown - name: Run regression tests - run: bash tools~/run-regression-tests.sh SpacetimeDB~ + run: bash sdks/csharp/tools~/run-regression-tests.sh . - name: Publish unity-tests module to SpacetimeDB - working-directory: unity-tests~/server-rust + working-directory: demo/Blackholio/server-rust run: | spacetime logout && spacetime login --server-issued-login local bash ./publish.sh - name: Patch com.clockworklabs.spacetimedbsdk dependency in manifest.json - working-directory: unity-tests~/client-unity/Packages + working-directory: demo/Blackholio/client-unity/Packages run: | # Replace the com.clockworklabs.spacetimedbsdk dependency with the current branch. - # TODO: find out why pointing to a local directory doesn't work - is it because Unity CI action uses Docker? - yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk.git#${{ github.head_ref }}"' manifest.json + # Note: Pointing to a local directory does not work, because our earlier steps nuke our meta files, which then causes Unity to not properly respect the DLLs (e.g. + # codegen does not work properly). + yq e -i '.dependencies["com.clockworklabs.spacetimedbsdk"] = "https://github.com/clockworklabs/SpacetimeDB.git?path=sdks/csharp#${{ github.head_ref }}"' manifest.json cat manifest.json - uses: actions/cache@v3 with: - path: unity-tests~/client-unity/Library + path: demo/Blackholio/client-unity/Library key: Unity-${{ github.head_ref }} restore-keys: Unity- @@ -162,7 +132,7 @@ jobs: uses: game-ci/unity-test-runner@v4 with: unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag - projectPath: unity-tests~/client-unity # Path to the Unity project subdirectory + projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory githubToken: ${{ secrets.GITHUB_TOKEN }} testMode: playmode useHostNetwork: true diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleDecay.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleDecay.g.cs index dc561ad3af5..c447ac50729 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleDecay.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleDecay.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void CircleDecay(CircleDecayTimer timer) public bool InvokeCircleDecay(ReducerEventContext ctx, Reducer.CircleDecay args) { - if (OnCircleDecay == null) return false; + if (OnCircleDecay == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnCircleDecay( ctx, args.Timer @@ -37,7 +50,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class CircleDecay : Reducer, IReducerArgs { - [DataMember(Name = "timer")] + [DataMember(Name = "_timer")] public CircleDecayTimer Timer; public CircleDecay(CircleDecayTimer Timer) @@ -50,7 +63,7 @@ public CircleDecay() this.Timer = new(); } - string IReducerArgs.ReducerName => "CircleDecay"; + string IReducerArgs.ReducerName => "circle_decay"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleRecombine.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleRecombine.g.cs index 5819e86e8a8..c3e7cb8c402 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleRecombine.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/CircleRecombine.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void CircleRecombine(CircleRecombineTimer timer) public bool InvokeCircleRecombine(ReducerEventContext ctx, Reducer.CircleRecombine args) { - if (OnCircleRecombine == null) return false; + if (OnCircleRecombine == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnCircleRecombine( ctx, args.Timer @@ -50,7 +63,7 @@ public CircleRecombine() this.Timer = new(); } - string IReducerArgs.ReducerName => "CircleRecombine"; + string IReducerArgs.ReducerName => "circle_recombine"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Connect.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Connect.g.cs index 7079a258424..03b6448fc3f 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Connect.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Connect.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -17,7 +19,18 @@ public sealed partial class RemoteReducers : RemoteBase public bool InvokeConnect(ReducerEventContext ctx, Reducer.Connect args) { - if (OnConnect == null) return false; + if (OnConnect == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnConnect( ctx ); @@ -31,7 +44,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class Connect : Reducer, IReducerArgs { - string IReducerArgs.ReducerName => "Connect"; + string IReducerArgs.ReducerName => "connect"; } } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/ConsumeEntity.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/ConsumeEntity.g.cs index a06bafd03eb..c730f1fd44c 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/ConsumeEntity.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/ConsumeEntity.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void ConsumeEntity(ConsumeEntityTimer request) public bool InvokeConsumeEntity(ReducerEventContext ctx, Reducer.ConsumeEntity args) { - if (OnConsumeEntity == null) return false; + if (OnConsumeEntity == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnConsumeEntity( ctx, args.Request @@ -50,7 +63,7 @@ public ConsumeEntity() this.Request = new(); } - string IReducerArgs.ReducerName => "ConsumeEntity"; + string IReducerArgs.ReducerName => "consume_entity"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Disconnect.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Disconnect.g.cs index 7943e6018a2..91f7377c06c 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Disconnect.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Disconnect.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -17,7 +19,18 @@ public sealed partial class RemoteReducers : RemoteBase public bool InvokeDisconnect(ReducerEventContext ctx, Reducer.Disconnect args) { - if (OnDisconnect == null) return false; + if (OnDisconnect == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnDisconnect( ctx ); @@ -31,7 +44,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class Disconnect : Reducer, IReducerArgs { - string IReducerArgs.ReducerName => "Disconnect"; + string IReducerArgs.ReducerName => "disconnect"; } } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/EnterGame.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/EnterGame.g.cs index 6db2cc2317d..52dd6e2927b 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/EnterGame.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/EnterGame.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void EnterGame(string name) public bool InvokeEnterGame(ReducerEventContext ctx, Reducer.EnterGame args) { - if (OnEnterGame == null) return false; + if (OnEnterGame == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnEnterGame( ctx, args.Name @@ -50,7 +63,7 @@ public EnterGame() this.Name = ""; } - string IReducerArgs.ReducerName => "EnterGame"; + string IReducerArgs.ReducerName => "enter_game"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/MoveAllPlayers.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/MoveAllPlayers.g.cs index b98d38d2ddb..2bc614a5a49 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/MoveAllPlayers.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/MoveAllPlayers.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void MoveAllPlayers(MoveAllPlayersTimer timer) public bool InvokeMoveAllPlayers(ReducerEventContext ctx, Reducer.MoveAllPlayers args) { - if (OnMoveAllPlayers == null) return false; + if (OnMoveAllPlayers == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnMoveAllPlayers( ctx, args.Timer @@ -37,7 +50,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class MoveAllPlayers : Reducer, IReducerArgs { - [DataMember(Name = "timer")] + [DataMember(Name = "_timer")] public MoveAllPlayersTimer Timer; public MoveAllPlayers(MoveAllPlayersTimer Timer) @@ -50,7 +63,7 @@ public MoveAllPlayers() this.Timer = new(); } - string IReducerArgs.ReducerName => "MoveAllPlayers"; + string IReducerArgs.ReducerName => "move_all_players"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/PlayerSplit.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/PlayerSplit.g.cs index 9063fa32be2..526264c5fa0 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/PlayerSplit.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/PlayerSplit.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void PlayerSplit() public bool InvokePlayerSplit(ReducerEventContext ctx, Reducer.PlayerSplit args) { - if (OnPlayerSplit == null) return false; + if (OnPlayerSplit == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnPlayerSplit( ctx ); @@ -36,7 +49,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class PlayerSplit : Reducer, IReducerArgs { - string IReducerArgs.ReducerName => "PlayerSplit"; + string IReducerArgs.ReducerName => "player_split"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Respawn.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Respawn.g.cs index d43bbdfc3b4..4b3bef3da36 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Respawn.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Respawn.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void Respawn() public bool InvokeRespawn(ReducerEventContext ctx, Reducer.Respawn args) { - if (OnRespawn == null) return false; + if (OnRespawn == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnRespawn( ctx ); @@ -36,7 +49,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class Respawn : Reducer, IReducerArgs { - string IReducerArgs.ReducerName => "Respawn"; + string IReducerArgs.ReducerName => "respawn"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/SpawnFood.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/SpawnFood.g.cs index 825d1ffe7a4..93a85902331 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/SpawnFood.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/SpawnFood.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void SpawnFood(SpawnFoodTimer timer) public bool InvokeSpawnFood(ReducerEventContext ctx, Reducer.SpawnFood args) { - if (OnSpawnFood == null) return false; + if (OnSpawnFood == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnSpawnFood( ctx, args.Timer @@ -37,7 +50,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class SpawnFood : Reducer, IReducerArgs { - [DataMember(Name = "timer")] + [DataMember(Name = "_timer")] public SpawnFoodTimer Timer; public SpawnFood(SpawnFoodTimer Timer) @@ -50,7 +63,7 @@ public SpawnFood() this.Timer = new(); } - string IReducerArgs.ReducerName => "SpawnFood"; + string IReducerArgs.ReducerName => "spawn_food"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Suicide.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Suicide.g.cs index 59dc9b5f2e1..ec98a781441 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Suicide.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/Suicide.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void Suicide() public bool InvokeSuicide(ReducerEventContext ctx, Reducer.Suicide args) { - if (OnSuicide == null) return false; + if (OnSuicide == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnSuicide( ctx ); @@ -36,7 +49,7 @@ public abstract partial class Reducer [DataContract] public sealed partial class Suicide : Reducer, IReducerArgs { - string IReducerArgs.ReducerName => "Suicide"; + string IReducerArgs.ReducerName => "suicide"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/UpdatePlayerInput.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/UpdatePlayerInput.g.cs index d1dfbfd977f..1d4dc7c3613 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/UpdatePlayerInput.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Reducers/UpdatePlayerInput.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -22,7 +24,18 @@ public void UpdatePlayerInput(DbVector2 direction) public bool InvokeUpdatePlayerInput(ReducerEventContext ctx, Reducer.UpdatePlayerInput args) { - if (OnUpdatePlayerInput == null) return false; + if (OnUpdatePlayerInput == null) + { + if (InternalOnUnhandledReducerError != null) + { + switch (ctx.Event.Status) + { + case Status.Failed(var reason): InternalOnUnhandledReducerError(ctx, new Exception(reason)); break; + case Status.OutOfEnergy(var _): InternalOnUnhandledReducerError(ctx, new Exception("out of energy")); break; + } + } + return false; + } OnUpdatePlayerInput( ctx, args.Direction @@ -50,7 +63,7 @@ public UpdatePlayerInput() this.Direction = new(); } - string IReducerArgs.ReducerName => "UpdatePlayerInput"; + string IReducerArgs.ReducerName => "update_player_input"; } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/SpacetimeDBClient.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/SpacetimeDBClient.g.cs index 3ba835f5d8c..1ced03e5037 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/SpacetimeDBClient.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/SpacetimeDBClient.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; @@ -14,6 +16,7 @@ public sealed partial class RemoteReducers : RemoteBase { internal RemoteReducers(DbConnection conn, SetReducerFlags flags) : base(conn) => SetCallReducerFlags = flags; internal readonly SetReducerFlags SetCallReducerFlags; + internal event Action? InternalOnUnhandledReducerError; } public sealed partial class RemoteTables : RemoteTablesBase @@ -36,7 +39,10 @@ public RemoteTables(DbConnection conn) public sealed partial class SetReducerFlags { } - public interface IRemoteDbContext : IDbContext { } + public interface IRemoteDbContext : IDbContext + { + public event Action? OnUnhandledReducerError; + } public sealed class EventContext : IEventContext, IRemoteDbContext { @@ -98,6 +104,14 @@ public void Disconnect() /// Get this connection's ConnectionId. /// public ConnectionId ConnectionId => conn.ConnectionId; + /// + /// Register a callback to be called when a reducer with no handler returns an error. + /// + public event Action? OnUnhandledReducerError + { + add => Reducers.InternalOnUnhandledReducerError += value; + remove => Reducers.InternalOnUnhandledReducerError -= value; + } internal EventContext(DbConnection conn, Event Event) { @@ -165,6 +179,14 @@ public void Disconnect() /// Get this connection's ConnectionId. /// public ConnectionId ConnectionId => conn.ConnectionId; + /// + /// Register a callback to be called when a reducer with no handler returns an error. + /// + public event Action? OnUnhandledReducerError + { + add => Reducers.InternalOnUnhandledReducerError += value; + remove => Reducers.InternalOnUnhandledReducerError -= value; + } internal ReducerEventContext(DbConnection conn, ReducerEvent reducerEvent) { @@ -239,6 +261,14 @@ public void Disconnect() /// Get this connection's ConnectionId. /// public ConnectionId ConnectionId => conn.ConnectionId; + /// + /// Register a callback to be called when a reducer with no handler returns an error. + /// + public event Action? OnUnhandledReducerError + { + add => Reducers.InternalOnUnhandledReducerError += value; + remove => Reducers.InternalOnUnhandledReducerError -= value; + } internal ErrorContext(DbConnection conn, Exception error) { @@ -302,6 +332,14 @@ public void Disconnect() /// Get this connection's ConnectionId. /// public ConnectionId ConnectionId => conn.ConnectionId; + /// + /// Register a callback to be called when a reducer with no handler returns an error. + /// + public event Action? OnUnhandledReducerError + { + add => Reducers.InternalOnUnhandledReducerError += value; + remove => Reducers.InternalOnUnhandledReducerError -= value; + } internal SubscriptionEventContext(DbConnection conn) { @@ -356,11 +394,11 @@ Action callback /// /// Subscribe to the following SQL queries. - /// + /// /// This method returns immediately, with the data not yet added to the DbConnection. /// The provided callbacks will be invoked once the data is returned from the remote server. /// Data from all the provided queries will be returned at the same time. - /// + /// /// See the SpacetimeDB SQL docs for more information on SQL syntax: /// https://spacetimedb.com/docs/sql /// @@ -439,18 +477,18 @@ protected override Reducer ToReducer(TransactionUpdate update) var encodedArgs = update.ReducerCall.Args; return update.ReducerCall.ReducerName switch { - "CircleDecay" => BSATNHelpers.Decode(encodedArgs), - "CircleRecombine" => BSATNHelpers.Decode(encodedArgs), - "Connect" => BSATNHelpers.Decode(encodedArgs), - "ConsumeEntity" => BSATNHelpers.Decode(encodedArgs), - "Disconnect" => BSATNHelpers.Decode(encodedArgs), - "EnterGame" => BSATNHelpers.Decode(encodedArgs), - "MoveAllPlayers" => BSATNHelpers.Decode(encodedArgs), - "PlayerSplit" => BSATNHelpers.Decode(encodedArgs), - "Respawn" => BSATNHelpers.Decode(encodedArgs), - "SpawnFood" => BSATNHelpers.Decode(encodedArgs), - "Suicide" => BSATNHelpers.Decode(encodedArgs), - "UpdatePlayerInput" => BSATNHelpers.Decode(encodedArgs), + "circle_decay" => BSATNHelpers.Decode(encodedArgs), + "circle_recombine" => BSATNHelpers.Decode(encodedArgs), + "connect" => BSATNHelpers.Decode(encodedArgs), + "consume_entity" => BSATNHelpers.Decode(encodedArgs), + "disconnect" => BSATNHelpers.Decode(encodedArgs), + "enter_game" => BSATNHelpers.Decode(encodedArgs), + "move_all_players" => BSATNHelpers.Decode(encodedArgs), + "player_split" => BSATNHelpers.Decode(encodedArgs), + "respawn" => BSATNHelpers.Decode(encodedArgs), + "spawn_food" => BSATNHelpers.Decode(encodedArgs), + "suicide" => BSATNHelpers.Decode(encodedArgs), + "update_player_input" => BSATNHelpers.Decode(encodedArgs), var reducer => throw new ArgumentOutOfRangeException("Reducer", $"Unknown reducer {reducer}") }; } @@ -489,5 +527,10 @@ protected override bool Dispatch(IReducerEventContext context, Reducer reducer) } public SubscriptionBuilder SubscriptionBuilder() => new(this); + public event Action OnUnhandledReducerError + { + add => Reducers.InternalOnUnhandledReducerError += value; + remove => Reducers.InternalOnUnhandledReducerError -= value; + } } } diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Circle.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Circle.g.cs index 391d3727b78..7492464f557 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Circle.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Circle.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleDecayTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleDecayTimer.g.cs index db8fe6a8373..d9008d835e2 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleDecayTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleDecayTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleRecombineTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleRecombineTimer.g.cs index aa64283f0fd..f535d853087 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleRecombineTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/CircleRecombineTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Config.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Config.g.cs index 8c8b5a79743..af5b3871de0 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Config.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Config.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/ConsumeEntityTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/ConsumeEntityTimer.g.cs index 335a6674868..070d6e744ca 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/ConsumeEntityTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/ConsumeEntityTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Entity.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Entity.g.cs index 0404666a069..290aeb2b369 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Entity.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Entity.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Food.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Food.g.cs index ee7b5fc4356..2ebfe844a8d 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Food.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Food.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/LoggedOutPlayer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/LoggedOutPlayer.g.cs index 71ac0a7832d..ca36a46d3e1 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/LoggedOutPlayer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/LoggedOutPlayer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/MoveAllPlayersTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/MoveAllPlayersTimer.g.cs index 105dd8e2a14..1fd98eebd24 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/MoveAllPlayersTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/MoveAllPlayersTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Player.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Player.g.cs index 8934ec93194..9b792f6c8e9 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Player.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/Player.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/SpawnFoodTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/SpawnFoodTimer.g.cs index 98d97340c04..34fb4e058f2 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/SpawnFoodTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Tables/SpawnFoodTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Circle.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Circle.g.cs index 2afa3afe79b..e9b886a8ad7 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Circle.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Circle.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleDecayTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleDecayTimer.g.cs index 922691cdbee..632305190dc 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleDecayTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleDecayTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleRecombineTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleRecombineTimer.g.cs index 0c370499a5b..713de4d19f8 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleRecombineTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/CircleRecombineTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Config.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Config.g.cs index c7c0d766860..c331df9b59e 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Config.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Config.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/ConsumeEntityTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/ConsumeEntityTimer.g.cs index cf120601bd0..9e8fe78e7d2 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/ConsumeEntityTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/ConsumeEntityTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/DbVector2.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/DbVector2.g.cs index c8667485ab6..ded362d5cea 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/DbVector2.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/DbVector2.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Entity.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Entity.g.cs index 578a64bdfca..36b59b9eee9 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Entity.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Entity.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Food.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Food.g.cs index 7b56ec0d1a7..9ca34adfda8 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Food.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Food.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/MoveAllPlayersTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/MoveAllPlayersTimer.g.cs index a9232130384..1b095fc06b2 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/MoveAllPlayersTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/MoveAllPlayersTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Player.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Player.g.cs index 5e9176c4293..1ea6f67004f 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Player.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/Player.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/SpawnFoodTimer.g.cs b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/SpawnFoodTimer.g.cs index 90d0fc058b9..f8357fcf9dd 100644 --- a/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/SpawnFoodTimer.g.cs +++ b/demo/Blackholio/client-unity/Assets/Scripts/autogen/Types/SpawnFoodTimer.g.cs @@ -1,6 +1,8 @@ // THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE // WILL NOT BE SAVED. MODIFY TABLES IN YOUR MODULE SOURCE CODE INSTEAD. +// This was generated using spacetimedb cli version 1.2.0 (commit ). + #nullable enable using System; diff --git a/demo/Blackholio/client-unity/Packages/manifest.json b/demo/Blackholio/client-unity/Packages/manifest.json index 648ae6519da..5af5941fae7 100644 --- a/demo/Blackholio/client-unity/Packages/manifest.json +++ b/demo/Blackholio/client-unity/Packages/manifest.json @@ -1,6 +1,6 @@ { "dependencies": { - "com.clockworklabs.spacetimedbsdk": "https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk.git", + "com.clockworklabs.spacetimedbsdk": "file:../../../../sdks/csharp", "com.unity.collab-proxy": "2.3.1", "com.unity.feature.2d": "2.0.1", "com.unity.ide.rider": "3.0.28", diff --git a/demo/Blackholio/client-unity/Packages/packages-lock.json b/demo/Blackholio/client-unity/Packages/packages-lock.json index 9f516820bd0..fc3a00d65ea 100644 --- a/demo/Blackholio/client-unity/Packages/packages-lock.json +++ b/demo/Blackholio/client-unity/Packages/packages-lock.json @@ -1,11 +1,10 @@ { "dependencies": { "com.clockworklabs.spacetimedbsdk": { - "version": "git@github.com:clockworklabs/com.clockworklabs.spacetimedbsdk.git#staging", + "version": "file:../../../../sdks/csharp", "depth": 0, - "source": "git", - "dependencies": {}, - "hash": "812e7c3e014005d31a5af41097b9c64a04c8c7df" + "source": "local", + "dependencies": {} }, "com.unity.2d.animation": { "version": "9.1.1", @@ -587,4 +586,4 @@ } } } -} \ No newline at end of file +} diff --git a/demo/Blackholio/server-rust/Cargo.toml b/demo/Blackholio/server-rust/Cargo.toml index 74ea840f894..1acb7c7f811 100644 --- a/demo/Blackholio/server-rust/Cargo.toml +++ b/demo/Blackholio/server-rust/Cargo.toml @@ -5,6 +5,10 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +# Put this in an empty workspace. This is required because we're nested under the SpacetimeDB root +# dir, which has its own workspace `Cargo.toml`, and this shouldn't think it's a part of that. +[workspace] + [lib] crate-type = ["cdylib"] diff --git a/sdks/csharp/.github/pull_request_template.md b/sdks/csharp/.github/pull_request_template.md deleted file mode 100644 index 5b1874d9ceb..00000000000 --- a/sdks/csharp/.github/pull_request_template.md +++ /dev/null @@ -1,21 +0,0 @@ -## Description of Changes -*Describe what has been changed, any new features or bug fixes* - -## API - - - [ ] This is an API breaking change to the SDK - -*If the API is breaking, please state below what will break* - -## Requires SpacetimeDB PRs -*List any PRs here that are required for this SDK change to work* - -## Testsuite -*If you would like to run the your SDK changes in this PR against a specific SpacetimeDB branch, specify that here. This can be a branch name or a link to a PR.* - -SpacetimeDB branch name: master - -## Testing -*Write instructions for a test that you performed for this PR* - -- [ ] Describe a test for this PR that you have completed diff --git a/sdks/csharp/.github/workflows/check-pr-base.yml b/sdks/csharp/.github/workflows/check-pr-base.yml deleted file mode 100644 index 0f401c5bc96..00000000000 --- a/sdks/csharp/.github/workflows/check-pr-base.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Git tree checks - -on: - pull_request: - types: [opened, edited, reopened, synchronize] - -permissions: - pull-requests: write - contents: read - -jobs: - check_base_ref: - name: Release branch restriction - runs-on: ubuntu-latest - steps: - - name: Change base to master if needed - if: | - github.event_name == 'pull_request' && - github.event.pull_request.base.ref == 'release/latest' && - ! startsWith(github.event.pull_request.head.ref, 'release/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - echo 'Updating PR '"#${{ github.event.pull_request.number }}"' to use base `master`' - echo 'If you do want to release your changes directly by merging into `release/latest`, your branch must start with `release/`.' - - curl -X PATCH \ - -H "Authorization: Bearer $GITHUB_TOKEN" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }} \ - -d '{"base": "master"}' diff --git a/sdks/csharp/.gitmodules b/sdks/csharp/.gitmodules deleted file mode 100644 index 50c54dcb4b7..00000000000 --- a/sdks/csharp/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "SpacetimeDBCircleGame"] - path = unity-tests~ - url = https://github.com/clockworklabs/SpacetimeDBCircleGame diff --git a/sdks/csharp/DEVELOP.md b/sdks/csharp/DEVELOP.md index e6cb9f31e6a..9f8f56654d2 100644 --- a/sdks/csharp/DEVELOP.md +++ b/sdks/csharp/DEVELOP.md @@ -1,3 +1,7 @@ +# Migration note + +We are in the process of moving from the `com.clockworklabs.spacetimedbsdk` repo to the `sdks/csharp` subdirectory of [SpacetimeDB](https://github.com/clockworklabs/SpacetimeDB). **Any new changes should be made there**. The `com.clockworklabs.spacetimedbsdk` repo will only be updated on release. Apologies in advance for any sharp edges while the migration is in progress. + # Notes for maintainers ## `SpacetimeDB.ClientApi` diff --git a/sdks/csharp/README.md b/sdks/csharp/README.md index 6cd3173b73d..3f9e10a6ba4 100644 --- a/sdks/csharp/README.md +++ b/sdks/csharp/README.md @@ -10,5 +10,4 @@ The Unity SDK uses the same code as the C# SDK. You can find the documentation f There is also a comprehensive Unity tutorial/demo available: - [Unity Tutorial](https://spacetimedb.com/docs/unity/part-1) Doc -- [Unity Demo](https://github.com/clockworklabs/Blackholio) Repo -- \ No newline at end of file +- [Unity Demo](https://github.com/clockworklabs/SpacetimeDB/tree/master/demo/Blackholio) Repo diff --git a/sdks/csharp/unity-tests~ b/sdks/csharp/unity-tests~ deleted file mode 160000 index c7797b68518..00000000000 --- a/sdks/csharp/unity-tests~ +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c7797b68518fa1b2441adc4dde14b05ad484e8de