Skip to content

Import C#/Unity SDK #2951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 230 commits into from
Jul 20, 2025
Merged

Import C#/Unity SDK #2951

merged 230 commits into from
Jul 20, 2025

Conversation

bfops
Copy link
Collaborator

@bfops bfops commented Jul 17, 2025

Description of Changes

Merge the spacetime-docs repo contents into a subdirectory of this repo, completely unchanged. The corresponding branches have already been pushed as csharp/[original branch name].

We will mirror this to com.clockworklabs.spacetimedbsdk for now, and update the release/latest branch and create tags there when we do a release.

This should be merged with a merge commit, for two reasons:

  1. To maintain the commit history of the merged repo (a squash commit would make all of the history prunable since it wouldn't be relevant anymore)
  2. So that migrated branches + PRs from the merged repo can merge in master without getting horrible merge conflicts (a squash commit would essentially newly create all of those files, causing merge conflicts)

Because of that, I think we should skip the merge queue to merge this PR (so that we can use a merge commit). It's entirely new files, so it should not cause any issues for other PRs.

API and ABI breaking changes

None

Expected complexity level and risk

1

Testing

Clockwork Labs and others added 30 commits November 1, 2022 13:53
Add sslEnabled option to Connect function
* Fix compilation issue with master

* Initial push for SATS (still WIP)

* Small build fix

* Small update

* Updates from meeting with Tyler

* Fixed issues with LayoutExplicit and added some missing functions

* AlgebraicValue cleanup

* Copied changes from BitCraftMini

* Removed TypeDef

---------

Co-authored-by: Clockwork Labs <no-reply@clockworklabs.io>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
* Upload script to help deploying to our partners

* You have to specify hosts individually

* Small fix

* Another small fix - tested + working

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* Serialize byte arrays as hex

* Fix namespace

* Small fix

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* First pass

* Committing meta file

* Removed option type - unneeded

* Implementing new some converter

* Some converter updates

* Tons of fixes here

* Cleaned up the some/enum serialization implementation

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: John <no-reply@boppygames.gg>
Co-authored-by: John Detter <no-reply@boppygames.gg>
Co-authored-by: John Detter <no-reply@boppygames.gg>
* Several updates to the way ClientCache + processing updates works

* Client cache changes working

* Removed log statements

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* Copied changes from BitCraft

* Applied state diff changes

* State diffs complete

* Compilation fix

* Fix build issues

---------

Co-authored-by: John Detter <no-reply@boppygames.gg>
* Pulled SpacetimeUnitySDK from the BitCraft project

* Removed unused logs

* Removed primary key functionality

* Fix compilation issues with older version of C#

* Primary key client implementation

* Another row update fix

---------

Co-authored-by: John <no-reply@boppygames.gg>
* Pulled SpacetimeUnitySDK from the BitCraft project

* Removed unused logs

* Removed primary key functionality

* Fix compilation issues with older version of C#

---------

Co-authored-by: John <no-reply@boppygames.gg>
kazimuth and others added 17 commits May 12, 2025 20:55
Update DLLs and generated code for SpacetimeDB 74ad4a1
## Description of Changes
Leverages #2725 to
speed up row deserialization. Also updates DLLs for recent upstream
fixes.

Changes:
- Uses much simpler code when deserializing enums, avoiding the use of
reflection
- Uses manually monomorphized row deserialization methods, which again
avoid the use of reflection when constructing row objects

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
#2725

## Testsuite

SpacetimeDB branch name: jgilles/perf/faster-allocation

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Blackholio
- [x] Bitcraft (have done a basic test but no in-depth testing)
## Description of Changes
Recreating #311 using a branch in this repo in the hope of fixing the
Unity build.

## API

 - [ ] This is an API breaking change to the SDK


## Requires SpacetimeDB PRs

## Testsuite

SpacetimeDB branch name: master

## Testing

- [x] blackholio
- [ ] bitcraft

---------

Co-authored-by: Guribo <guribovr@gmail.com>
## Description of Changes
Just bumping version numbers in preparation for a release.

The Unity SDK and C# SDK had different version numbers. That seems
confusing, so I bumped them both to 1.1.5.

## API

No breaking changes

## Requires SpacetimeDB PRs
None, afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
None

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
Update DLLs to the 1.1.2 versions that have been pushed to NuGet.

The SpacetimeDB tag that they were built from is
`v1.1.2-csharp-release`.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs
None, because we're updating the DLLs to essentially include SpacetimeDB
PRs.

## Testsuite
SpacetimeDB branch name: master

## Testing
CI I guess?

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
Bump versions to 1.2.0, as well as update the DLLs from SpacetimeDB
(commit `fc8f7dcc8`). They don't have any changes, but the versions
needed bumping.

## API

This itself is not a breaking changes.

## Requires SpacetimeDB PRs
#2837

## Testsuite
SpacetimeDB branch name: release/v1.2.0

## Testing
CI only

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## 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

---------

Co-authored-by: Alessandro Asoni <alessandro@clockworklabs.io>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
## Description of Changes
`NetworkRequestTracker` previously was keeping all historical reducer
request data, and searching through this every frame to get statistics.
I've modified it to throw out much more data -- it's much faster now,
but only updates every few seconds.

## API

Not an API break, but deprecates an argument of one of
NetworkRequestTracker's methods to no longer do anything.

Adds new APIs.

## Requires SpacetimeDB PRs
N/A

## Testsuite

SpacetimeDB branch name: master

## Testing

- [x] Tested Bitcraft. **Their F9 debug menu will require an update,
since we now only keep one time window of request data, rather than
being able to give information about multiple windows.** But it works.
- [x] Blackholio CI
## Description of Changes
Addresses
clockworklabs/SpacetimeDBPrivate#1786 and
clockworklabs/com.clockworklabs.spacetimedbsdk#329.
Marks messages as parsed from the background parsing thread, and then
marks them as applied using a separate tracker once they are applied.

## API

 - [ ] This is an API breaking change to the SDK

*If the API is breaking, please state below what will break*

## Requires SpacetimeDB PRs

## Testsuite

SpacetimeDB branch name: master

## Testing

- [x] Testing against Bitcraft
## Description of Changes
Updates the DLLs for
#2762, and bumps our
version numbers as well.

## API

 - [ ] This is an API breaking change to the SDK

Not a breaking change

## Requires SpacetimeDB PRs
None afaik

## Testsuite
SpacetimeDB branch name: master

## Testing
*Write instructions for a test that you performed for this PR*

- [x] Ran through Bitcraft tutorial
- [x] Blackholio on CI

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
These version bumps were supposed to happen in
clockworklabs/com.clockworklabs.spacetimedbsdk#332,
but apparently I messed something up while I was switching branches.

## API

 - [ ] This is an API breaking change to the SDK

No breaking changes

## Requires SpacetimeDB PRs
None.

## Testsuite
SpacetimeDB branch name: master

## Testing
CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
Missed in
clockworklabs/com.clockworklabs.spacetimedbsdk#333.

We should update the 1.2.1 tag and the `release/latest` branch after
this.

## API

 - [ ] This is an API breaking change to the SDK

Nope

## Requires SpacetimeDB PRs
None

## Testsuite
SpacetimeDB branch name: master

## Testing
CI only

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
I'm tired of messing up version updates. I "vibecoded" a script to do
it.

## API

 - [ ] This is an API breaking change to the SDK

No. No changes to runtime code.

## Requires SpacetimeDB PRs
None

## Testsuite
SpacetimeDB branch name: master

## Testing
```
$ python3 tools~/update-version.py 1.1.1
Updated: ./SpacetimeDB.ClientSDK.csproj
Updated: ./tests~/tests.csproj
Updated: ./examples~/regression-tests/server/StdbModule.csproj
Updated: ./examples~/regression-tests/client/client.csproj
Updated: ./examples~/quickstart-chat/server/StdbModule.csproj
Updated: ./examples~/quickstart-chat/client/client.csproj
Updated version in package.json to 1.1.1

$ git diff -U1
diff --git a/SpacetimeDB.ClientSDK.csproj b/SpacetimeDB.ClientSDK.csproj
index 5248df6..b3ca7e8 100644
--- a/SpacetimeDB.ClientSDK.csproj
+++ b/SpacetimeDB.ClientSDK.csproj
@@ -18,4 +18,4 @@
     <RepositoryUrl>https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk</RepositoryUrl>
-    <AssemblyVersion>1.2.1</AssemblyVersion>
-    <Version>1.2.1</Version>
+    <AssemblyVersion>1.1.1</AssemblyVersion>
+    <Version>1.1.1</Version>
     <DefaultItemExcludes>$(DefaultItemExcludes);*~/**</DefaultItemExcludes>
@@ -27,3 +27,3 @@
   <ItemGroup>
-    <PackageReference Include="SpacetimeDB.BSATN.Runtime" Version="1.2.*" />
+    <PackageReference Include="SpacetimeDB.BSATN.Runtime" Version="1.1.*" />
 
diff --git a/examples~/quickstart-chat/server/StdbModule.csproj b/examples~/quickstart-chat/server/StdbModule.csproj
index 0513a81..f290d22 100644
--- a/examples~/quickstart-chat/server/StdbModule.csproj
+++ b/examples~/quickstart-chat/server/StdbModule.csproj
@@ -16,3 +16,3 @@
   <ItemGroup>
-    <PackageReference Include="SpacetimeDB.Runtime" Version="1.2.*" />
+    <PackageReference Include="SpacetimeDB.Runtime" Version="1.1.*" />
   </ItemGroup>
diff --git a/examples~/regression-tests/server/StdbModule.csproj b/examples~/regression-tests/server/StdbModule.csproj
index c6b1cba..3284863 100644
--- a/examples~/regression-tests/server/StdbModule.csproj
+++ b/examples~/regression-tests/server/StdbModule.csproj
@@ -10,3 +10,3 @@
   <ItemGroup>
-    <PackageReference Include="SpacetimeDB.Runtime" Version="1.2.*" />
+    <PackageReference Include="SpacetimeDB.Runtime" Version="1.1.*" />
   </ItemGroup>
diff --git a/package.json b/package.json
index 7839151..a627246 100644
--- a/package.json
+++ b/package.json
@@ -3,3 +3,3 @@
   "displayName": "SpacetimeDB SDK",
-  "version": "1.2.1",
+  "version": "1.1.1",
   "description": "The SpacetimeDB Client SDK is a software development kit (SDK) designed to interact with and manipulate SpacetimeDB modules..",
```

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
## Description of Changes
This is a fix for community bug
clockworklabs/com.clockworklabs.spacetimedbsdk#340
that was the result of changes to SpacetimeDBClient code that missed
changes to the WebGL build.

## API

 - [ ] This is an API breaking change to the SDK

## Requires SpacetimeDB PRs
- None

## Testsuite
SpacetimeDB branch name: master

## Testing

- [X] Tested changes against Blackholio running under a Unity WebGL
build
@bfops bfops marked this pull request as ready for review July 19, 2025 02:11
@bfops bfops requested a review from cloutiertyler as a code owner July 19, 2025 02:11
Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm approving, but I had a thought while looking at the license here, we should probably have the top level license.txt explain that each folder has its own license or something, then move the BuSL license into the appropriate places. Right now the BuSL is probably applying more places than it should. We can think/coord on this.

@bfops bfops merged commit bd9ea55 into master Jul 20, 2025
34 of 36 checks passed
@bfops bfops deleted the bfops/import-csharp branch July 20, 2025 06:02
@@ -0,0 +1,25 @@
name: Publish NuGet Package on Release
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this is quite nice now that when we send out a SpacetimeDB release it will also release the nuget package for us automatically. This is a huge improvement.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually don't know that we want that - not all SpacetimeDB releases are tied to C# SDK releases (and vice-versa)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I guess it's not true in the general case that we always want to send out C# SDK updates for every SpacetimeDB release (especially for minor version bumps)

@jdetter
Copy link
Collaborator

jdetter commented Jul 21, 2025

There are 2 major things we have to do next:

  1. The original com.clockworklabs.spacetimedbsdk repo should become a mirror of this subdirectory. Some questions to answer:
  • How does this affect our default branch in the com.clockworklabs.spacetimedbsdk repo? Should we keep it as release/latest?
  • Should we mirror all branches to com.clockworklabs.spacetimedbsdk? I think the answer is yes because then we can ship "testing" branches to BitCraft and/or other clients without having to manually create that branch.
  1. Can we add a CI for whenever we update crates/csharp-bindings/* we regenerate the DLLs for that PR? Then when that PR merges the DLLs. Also tracking the DLLs within the SpacetimeDB repo is going to make the repo bloat pretty quickly, perhaps we consider git-lfs?

@bfops
Copy link
Collaborator Author

bfops commented Jul 21, 2025

There are 2 major things we have to do next:

  1. The original com.clockworklabs.spacetimedbsdk repo should become a mirror of this subdirectory. Some questions to answer:
  • How does this affect our default branch in the com.clockworklabs.spacetimedbsdk repo? Should we keep it as release/latest?

Yes, because the goal of the default branch is for users to get something sane if they just paste the repo URL into the Unity package manager.

  • Should we mirror all branches to com.clockworklabs.spacetimedbsdk? I think the answer is yes because then we can ship "testing" branches to BitCraft and/or other clients without having to manually create that branch.

I think not. If we want to give clients a particular branch, I believe we can link them to the SpacetimeDB repo directly with a subdirectory. I can add instructions on how to do this.

  1. Can we add a CI for whenever we update crates/csharp-bindings/* we regenerate the DLLs for that PR? Then when that PR merges the DLLs. Also tracking the DLLs within the SpacetimeDB repo is going to make the repo bloat pretty quickly, perhaps we consider git-lfs?

Yeah agreed, this automation becomes a bit easier now that the repos are merged. There's a separate ticket for it though. +1 to git lfs too!

@jdetter
Copy link
Collaborator

jdetter commented Jul 21, 2025

I think not. If we want to give clients a particular branch, I believe we can link them to the SpacetimeDB repo directly with a subdirectory. I can add instructions on how to do this.

Does this work for checking out a Unity package? Like can you checkout a subdirectory? Will that clone the entire repository?

@bfops
Copy link
Collaborator Author

bfops commented Jul 21, 2025

I think not. If we want to give clients a particular branch, I believe we can link them to the SpacetimeDB repo directly with a subdirectory. I can add instructions on how to do this.

Does this work for checking out a Unity package? Like can you checkout a subdirectory? Will that clone the entire repository?

I can't say whether it clones the entire repository, but yes you can check out a subdirectory. It's what we do in the unity testsuite in #2952.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.