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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
271e8ce
Initial commit for SpacetimeDBUnitySDK (squashed commit)
Nov 1, 2022
77b7c27
chmod +x export.sh
cloutiertyler Nov 1, 2022
6c014f6
Renamed arguments for connect. Changed connection URI to use URL
Nov 1, 2022
1f4f10b
Fix export script
Nov 1, 2022
e6670fe
Another fix to export script
Nov 1, 2022
5ac9a7e
Remove BitCraftMini from the SDK
Nov 2, 2022
ee03801
Some API updates
Nov 2, 2022
ddf626c
Merge pull request #1 from clockworklabs/jdetter/some-api-updates
jdetter Nov 2, 2022
63f4550
More API updates
Nov 2, 2022
a4727e6
Small fix
Nov 2, 2022
8eef49f
Merge pull request #2 from clockworklabs/jdetter/some-api-updates2
cloutiertyler Nov 2, 2022
df3742f
Improved names
Nov 3, 2022
e518ebe
.gitignore change
cloutiertyler Nov 3, 2022
789b5b2
Several fixes to sending when the websocket is closed.
Nov 3, 2022
7f4e27d
Give SDK users access to the token key
dbrinkmann-citadel Jan 11, 2023
c499710
Changes to the Unity SDK to support callbacks for individual table ro…
dbrinkmann-citadel Jan 13, 2023
dbd3387
Merge pull request #3 from clockworklabs/Derek-Callback-Improvements
dbrinkmanncw Jan 18, 2023
ec5fa25
Add sslEnabled option to Connect function
dbrinkmann-citadel Jan 20, 2023
a82c379
Merge pull request #4 from clockworklabs/derek-add-SSL-option
dbrinkmanncw Jan 23, 2023
2054da4
Migrate from TypeDef/TypeValue to SATS (#5)
jdetter Feb 26, 2023
0a52df6
SDK Upload Script (#7)
jdetter Feb 28, 2023
93cd63d
Json Byte Arrays Serialized as Hex (#8)
jdetter Mar 8, 2023
02cbdd0
C# Enum Generation (#9)
jdetter Mar 21, 2023
ac573a0
Fix compilation issue (#11)
jdetter Mar 23, 2023
fdca2f5
Automatically find Unity on macOS (#12)
jdetter Mar 24, 2023
5839fd4
GetEntries now returns both AlgebraicValue and object as a tuple (#15)
jdetter Apr 7, 2023
3d2a2a8
Use Network Thread for Processing DB Rows (#14)
jdetter Apr 7, 2023
a9b9bfc
State Diffs (#16)
jdetter Apr 21, 2023
63f5239
Primary Key Impl (#18)
jdetter Jun 8, 2023
c313629
SpacetimeDB SDK Version 0.4.1 (#17)
jdetter Jun 8, 2023
5e63631
Adding event parameter to table callbacks (#19)
SteveGibsonCL Jun 8, 2023
2a6e037
Fix compile error in sdk (#22)
dbrinkmanncw Jun 13, 2023
b1b9689
Add onSubscriptionUpdate callback (#21)
dbrinkmanncw Jun 14, 2023
91b3e23
Deserializing reducer args before table updates so they can be access…
SteveGibsonCL Jun 14, 2023
e806ee3
Reducer args in table updates 2 (#23)
SteveGibsonCL Jun 15, 2023
7737b98
Changed guid (#25)
SteveGibsonCL Jun 15, 2023
cf9c5b0
Fixed API (#26)
jdetter Jun 15, 2023
9382710
Reducer event (#28)
SteveGibsonCL Jun 16, 2023
85b8020
On before delete (#24)
SteveGibsonCL Jun 16, 2023
31dedc3
Renamed onSubscriptionUpdate to onSubscriptionApplied (#27)
jdetter Jun 16, 2023
351616e
Fixed occasional double insert (#30)
SteveGibsonCL Jun 19, 2023
4fb1975
Supporting multiple messages per frame (#29)
SteveGibsonCL Jun 19, 2023
8a74cfd
Custom indexes (#32)
SteveGibsonCL Jun 26, 2023
0a46b01
Convert Unity SDK into a CSharp SDK with Unity support (#34)
dbrinkmanncw Jun 30, 2023
bebd5db
Rename ILogger class to ISpacetimeDBLogger to avoid some annoying nam…
dbrinkmann-citadel Jul 5, 2023
de4ea64
search for reducer type using reflection instead of passing in
dbrinkmann-citadel Jul 5, 2023
76cd6ee
Fixed serialization issue + added jetbrains IDE files to gitignore (#37)
jdetter Jul 12, 2023
eee5131
Fix close and improve onConnectError message (#36)
dbrinkmanncw Jul 18, 2023
a0f8c48
Add optional component to handle saving auth token (#39)
dbrinkmanncw Jul 18, 2023
4990149
Fix Typeo (#40)
jdetter Jul 18, 2023
134834a
Use correct hashcode for identity (#45)
aasoni Jul 31, 2023
9b21d40
generate types to SpacetimeDB.Types namespace (#41)
dbrinkmanncw Aug 1, 2023
3bc803b
Fix using Identity as Primary Key (#43)
dbrinkmanncw Aug 1, 2023
c7dbe35
Created PR Template (#38)
jdetter Aug 2, 2023
1a95b38
Performance improvement for Del/Ins -> Update conversion (#47)
aasoni Aug 2, 2023
e0524fa
Update version to 0.6.0 (#48)
dbrinkmanncw Aug 2, 2023
1003db2
Commit quickstart example (#44)
dbrinkmanncw Aug 8, 2023
b08a03e
README.md and License.txt updates (#53)
dbrinkmanncw Oct 12, 2023
102061f
Release v0.7.0-beta (#56)
jdetter Oct 12, 2023
b2dbe89
Small 0.7.0 Fixes (#60)
jdetter Oct 12, 2023
819947c
Small updates to 0.7.0 (#61)
jdetter Oct 14, 2023
9c744a3
v0.7.2-beta Changes (#62)
jdetter Dec 21, 2023
f315960
Workflow for Publishing Nuget Package (#64)
jdetter Dec 21, 2023
d54c31a
Upgraded version to 0.8.0 (#66)
jdetter Dec 21, 2023
b170539
Fixed an issue where only one network packet was being processed per …
jdetter Feb 6, 2024
061f1c3
Added new callback - onBeforeSubscriptionApplied (#71)
jdetter Feb 6, 2024
75dc6b5
Remove the `rowPk` from the client API (#72)
gefjon Feb 28, 2024
e649c49
Add Brotli decompression (#75)
RReverser Mar 29, 2024
0ca2a54
Nit: remove unused `inserts` field (#77)
RReverser Apr 23, 2024
f6aa76c
Set language version to 9 (#80)
RReverser Apr 24, 2024
383ba27
Make logger a separate SDK setting from client instance (#79)
RReverser Apr 24, 2024
2fd9eb4
Fix nullability warnings in WebSocket class (#82)
RReverser Apr 25, 2024
eaa8fa0
Merge ByteArrayComparers (#78)
RReverser May 8, 2024
6b5b23d
Extract common logic from `OnMessageProcessComplete` (#81)
RReverser May 9, 2024
ce38cd1
NFC: remove unused primaryKeyValue field (#85)
RReverser May 9, 2024
1bb67c5
Remove RowUpdate event (#83)
RReverser May 10, 2024
c925af1
Fix conflict resolution shenanigans (#87)
RReverser May 13, 2024
8ca0484
Add basic CI (#88)
RReverser May 13, 2024
c8319eb
Simplify event dispatch in WebSocket (#90)
RReverser May 13, 2024
8db08a7
Switch to TaskCompletionSource (#89)
RReverser May 13, 2024
6ba3da5
Minor refactoring of AuthToken (#84)
RReverser May 14, 2024
125c5e7
NFC: inline insert/delete update handling (#86)
RReverser May 14, 2024
1af7233
Bump version for release v0.9 (#94)
kurtismullins May 22, 2024
ed6a3aa
Ignore duplicate inserts in the same subscription update (#92)
RReverser May 27, 2024
4819292
Simplify update handling as per consistent filtering proposal (#93)
RReverser May 28, 2024
92f5a17
Bump version to 0.9.2 (#95)
bfops May 28, 2024
7bafc7f
Switch to shared BSATN support (#97)
RReverser Jun 7, 2024
53d6f9c
Release v0.10.0 (#98)
bfops Jun 13, 2024
b648b9c
Autoformat & verify on CI
RReverser Jun 15, 2024
0267f02
Add snapshot-based tests
RReverser Jun 15, 2024
40f6138
Update API docs
RReverser Jun 15, 2024
17ce57f
Store test dump in a maintainable format
RReverser Jun 15, 2024
21e475b
Add Stats snapshot
RReverser Jun 15, 2024
e345452
Fix formatting
RReverser Jun 15, 2024
9c01734
Simplify Identity scrubbing
RReverser Jun 17, 2024
27120e8
Move Verify converters around
RReverser Jun 17, 2024
7e8a6ed
Update test snapshots
RReverser Jun 17, 2024
06285d3
Protobufectomy: c# sdk (#104)
lcodes Jul 11, 2024
706b945
Revert breaking change in message preprocessing (#106)
lcodes Jul 12, 2024
5e06506
CI - Use SpacetimeDB `master` when applicable (#108)
bfops Jul 24, 2024
554df35
0.11 upgrades (#101)
RReverser Jul 25, 2024
cd5f44b
CI - `push` events only trigger on pushes to `master` (#110)
bfops Jul 26, 2024
9fba156
Minor BSATN simplifications (#111)
RReverser Jul 29, 2024
5394c63
Don't use BuiltinType.I/U128, use AlgebraicType.I/U128 (#116)
Centril Aug 6, 2024
655c2cc
Restore `dotnet pack` functionality (#118)
bfops Aug 6, 2024
2efa162
Update DEVELOP.md to reflect new codegen (#119)
lcodes Aug 7, 2024
996633b
Nix `Primitives.cs` - types now defined in main repo (#120)
Centril Aug 13, 2024
cb59eba
Merge Unity SDK into C# SDK (#117)
RReverser Aug 28, 2024
e28849e
Revert `master` to a stable state (#123)
bfops Aug 29, 2024
e57e589
Don't use BuiltinType.I/U128, use AlgebraicType.I/U128 (#116)
Centril Aug 6, 2024
341be7f
Restore `dotnet pack` functionality (#118)
bfops Aug 6, 2024
5670db6
Update DEVELOP.md to reflect new codegen (#119)
lcodes Aug 7, 2024
2422b8c
Nix `Primitives.cs` - types now defined in main repo (#120)
Centril Aug 13, 2024
6312c45
Copy files from old repo (#127)
bfops Sep 10, 2024
589d404
Logging API (#132)
SteveGibsonCL Sep 23, 2024
76d30fe
c# client SDK (DbConnection + SDK Callbacks) (#131)
lcodes Oct 1, 2024
5c033a4
Subscription API (#137)
RReverser Oct 1, 2024
87a13eb
Merge table cache into table handle (#139)
RReverser Oct 1, 2024
113e8dd
Add DbConnection argument to OnConnect (#138)
lcodes Oct 1, 2024
cfd654f
Hide more APIs (#140)
RReverser Oct 1, 2024
b62a464
Implement websocket changes atop C# sdk changes (#136)
Centril Oct 2, 2024
cec6fb8
Fix UnityDebugLogger implementation (#143)
RReverser Oct 2, 2024
463a240
Tighten package sources in C# smoketests (#133)
RReverser Oct 2, 2024
9d3336e
Reduce public API surface further (#145)
RReverser Oct 2, 2024
fa87e36
Don't actually try to connect to network in tests (#144)
RReverser Oct 2, 2024
affa2af
Add script to generate `nuget.config` (#115)
bfops Oct 3, 2024
b96f1a6
Fix `gen-client-api` scripts for new CLI API (#151)
bfops Oct 3, 2024
76d275f
Remove obsolete tools folder (#149)
RReverser Oct 3, 2024
2c95bee
Try to catch flaky bugs (#150)
RReverser Oct 3, 2024
1b0e843
Jeremie/remove break (#154)
lcodes Oct 3, 2024
b320e5e
Update DLLs for 0.12.0 (#152)
bfops Oct 3, 2024
434c5ff
Accept multiple queries in Subscribe (#153)
RReverser Oct 4, 2024
2d20acd
Fix UnityNetworkManager (#141)
RReverser Oct 4, 2024
072d9ea
Upgrade SDK Version to 0.12 (#156)
jdetter Oct 4, 2024
d2143cc
Use SpacetimeDBNetworkManager everywhere (#157)
jdetter Oct 4, 2024
c3be5b0
Update to tests/examples follow codegen changes (#160)
lcodes Oct 4, 2024
f376c05
0.12.0 DLLs (again) (#161)
bfops Oct 4, 2024
1e13ab5
Jeremie/one off query decoupled from table (#163)
lcodes Oct 12, 2024
01a7e3f
Add gzip + none compression algos and let SDK pick compression (#155)
Centril Oct 15, 2024
035ee4b
Revert PR 155 (#173)
jdetter Oct 16, 2024
cf3f37c
Update DLLs and bump package versions to `1.0.0-rc1` (#180)
bfops Oct 29, 2024
5ccb5f9
Fixed subscription updates not clearing tables with no subscribed val…
SteveGibsonCL Oct 30, 2024
b2c5b41
Fix Connection Error: Success (#166)
jdetter Oct 30, 2024
b728e63
Unity testsuite as a git submodule (#186)
jdetter Oct 31, 2024
ac45eac
Add gzip + none compression algos and let SDK pick compression (take …
Centril Oct 31, 2024
f936c98
Fix Reconnection Logic (#168)
jdetter Oct 31, 2024
2ad31d6
Companion to SpacetimeDB#1812 (light tx, C#) (#170)
Centril Nov 4, 2024
181aff3
Update the quickstart module (#185)
lcodes Nov 4, 2024
82f4b07
Bump Unity SDK version to RC1 (#187)
bfops Nov 6, 2024
3054a7f
Bump version and update DLLs (#192)
bfops Nov 19, 2024
9b7f20c
Migrate C# and Unity tests to the new API (#194)
RReverser Dec 12, 2024
844713f
Updating unity-tests (#197)
cloutiertyler Dec 13, 2024
1a21af8
Bump versions
cloutiertyler Dec 14, 2024
d8277ff
Updated DLLs I think
cloutiertyler Dec 14, 2024
fa2baa6
Update pull_request_template.md
cloutiertyler Dec 12, 2024
a90e0f9
Fix CI (#205)
RReverser Jan 6, 2025
d6d78b3
fix(202): RemoteQuery should not SELECT * (#203)
joshua-spacetime Jan 6, 2025
bb6d624
Update Unity tests (#207)
RReverser Jan 7, 2025
006087f
Add delegates for events (#201)
RReverser Jan 14, 2025
11896cb
Bump version to RC3 and update DLLs (#210)
bfops Jan 14, 2025
39e7ebb
Revise `WithCredentials` to `WithToken` (#212)
gefjon Jan 14, 2025
2487c94
Add CI check for Unity meta files (#209)
RReverser Jan 14, 2025
0017af7
Disable PR comment for meta file check if not a PR (#216)
RReverser Jan 14, 2025
749825a
`SubscribeToAllTables`, which hides `"SELECT * FROM *"` (#211)
gefjon Jan 14, 2025
3d530ee
Upgrade to new regenerated client-api bindings (#218)
RReverser Jan 16, 2025
62e16c6
Unify CI handling of SpacetimeDB branch (#215)
RReverser Jan 23, 2025
6578f05
Implement new subscription API (#219)
kazimuth Jan 23, 2025
27be301
Bump version to `1.0.0-rc3-hotfix3` (#222)
bfops Jan 24, 2025
76194c2
Revert trunk branch versions to `1.0.0-rc3` (no hotfix) (#223)
bfops Jan 27, 2025
aa6cb5b
Revert DLLs to `1.0.0-rc3` (#224)
bfops Jan 27, 2025
82ad0a0
Bump version to `1.0.0-rc4` (#225)
bfops Jan 29, 2025
f4cc0b3
Improve CI caching (#228)
RReverser Feb 5, 2025
cefc727
Rewrite C# codegen to the new Lang infra + fixes (#220)
RReverser Feb 5, 2025
fed2a9d
Fix handling of multi-tables (#229)
RReverser Feb 6, 2025
b4aa612
Make Timestamp and TimeDuration special types (#233)
kazimuth Feb 7, 2025
9f58828
Rework event contexts in C# (#240)
kazimuth Feb 7, 2025
f966144
Update DLLs (#241)
bfops Feb 7, 2025
96d52c1
Rename `Address` to `ConnectionId` (#239)
gefjon Feb 10, 2025
498b25f
Emit Event.UnknownTransaction rather than throwing on unknown reducer…
kazimuth Feb 11, 2025
c6eded9
Adjust http api usage for glowup (#242)
coolreader18 Feb 11, 2025
076d4ec
Strip trailing `/` from URIs before connecting (#238)
bfops Feb 11, 2025
0386121
Switch to Bearer auth (#236)
coolreader18 Feb 11, 2025
b80a2b9
CI - Update release branch check (#246)
bfops Feb 13, 2025
083531e
SubscribeMulti + UnsubscribeMulti, multiplicities (#249)
kazimuth Feb 25, 2025
b1a9f96
Fix comment for SubscribeToAllTables (#256)
joshua-spacetime Feb 26, 2025
df1dcf2
Fix comment for SubscribeToAllTables (#259)
joshua-spacetime Feb 28, 2025
25689c1
Update C# server and client quickstart examples to match tutorial doc…
rekhoff Mar 3, 2025
e21566a
Update README (#260)
kazimuth Mar 4, 2025
60761bb
Bump versions to 1.0.0 (#253)
bfops Mar 4, 2025
421256a
Relax the version constraint on SpacetimeDB nuget package (#270)
bfops Mar 12, 2025
bbdb0fd
Minor Version Bump to 1.0.1 (#261)
jdetter Mar 12, 2025
9523ba3
Adds tests of GenericEqualityComparer (#271)
rekhoff Mar 13, 2025
4d3f0a0
Resolved 404 and references to deprecated tutorial repos. (#268)
rekhoff Mar 14, 2025
23c2dc0
Update DLLs to 1.0.1 (#269)
bfops Mar 14, 2025
89c019c
Bump package version to 1.0.1 (#272)
rekhoff Mar 14, 2025
d4267b3
Bump versions to 1.1.0 (#282)
bfops Mar 28, 2025
3543132
Fix for unsubscribe bug + regression tests (#264)
kazimuth Mar 28, 2025
468a6f1
Fix warning message for failed to track reducer call (#280)
jdetter Apr 12, 2025
7d25b03
Switch to a better index data structure (#291)
kazimuth Apr 14, 2025
f24b0e8
Update DLLs to 1.1.0 (#288)
bfops Apr 15, 2025
47e9638
Bump version in `package.json` (#293)
bfops Apr 15, 2025
f32754b
Fix row deduplication issues (#294)
kazimuth Apr 18, 2025
ce7828e
Bump versions to 1.1.1 (#297)
bfops Apr 22, 2025
0fa4cf9
CI - Release branch check auto-changes base branch (#298)
bfops Apr 22, 2025
20ed2dc
SpacetimeDB working in Unity WebGL Builds (#286)
Daxode Apr 22, 2025
c99c4cb
Update DLLs to 1.1.1 (#300)
bfops Apr 22, 2025
3ed21c4
Bump version to 1.1.2 (#301)
bfops Apr 23, 2025
b6f8362
Implement OnUnhandledReducerError (#295)
kazimuth Apr 23, 2025
5ad9baa
Pre-decompress query updates (#302)
kazimuth Apr 24, 2025
8756058
Version Bump 1.1.3 (#303)
jdetter Apr 24, 2025
78f5000
Bump version to 1.1.4 (#307)
jdetter Apr 25, 2025
590e873
Significantly reduce small byte array allocations (#305)
kazimuth Apr 26, 2025
3dabd47
Add comment on the performance of LINQ for reading BSATN (#309)
joshua-spacetime Apr 28, 2025
c813fb3
Fix list equals (#316)
kazimuth May 12, 2025
b46a894
Faster deserialization (#315)
kazimuth May 15, 2025
8bde94a
Recreate #311 (#317)
kazimuth May 15, 2025
c03b962
Bump versions to 1.1.5 (#320)
bfops May 21, 2025
a198fad
Update DLLs to 1.1.2 (#322)
bfops May 22, 2025
5baf66b
Bump versions to 1.2.0 (#328)
bfops Jun 6, 2025
544085c
Example of custom event handling (#327)
lisandroct Jun 6, 2025
e3b392a
Faster Stats.cs (#326)
kazimuth Jun 6, 2025
e168ec6
More granular request process tracking (#330)
kazimuth Jun 18, 2025
79de507
Bump to 1.2.1 (#332)
bfops Jun 23, 2025
d62d85a
Bump versions to 1.2.1 (#333)
bfops Jun 23, 2025
4b1cce2
Bump Unity package version to 1.2.1 (#334)
bfops Jun 23, 2025
6c419cc
Add `tools~/upgrade-version.py` (#335)
bfops Jun 25, 2025
533c14b
Update WebGL message queue to 1.2.1 format (#342)
rekhoff Jul 7, 2025
2c7b668
[bfops/import-csharp]: Merge remote-tracking branch 'temp-csharp-sdk/…
bfops Jul 17, 2025
07899d0
[bfops/import-csharp]: Merge remote-tracking branch 'origin/master' i…
bfops Jul 17, 2025
9bdb3ed
[bfops/import-csharp]: Merge remote-tracking branch 'origin/master' i…
bfops Jul 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions sdks/csharp/.github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## 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
31 changes: 31 additions & 0 deletions sdks/csharp/.github/workflows/check-pr-base.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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"}'
25 changes: 25 additions & 0 deletions sdks/csharp/.github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
@@ -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)


on:
release:
types: [published]

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8'
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
# - name: Test
# run: dotnet test --no-build
- name: Pack
run: dotnet pack --no-build --output nupkgs
- name: Publish
run: dotnet nuget push nupkgs/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json
172 changes: 172 additions & 0 deletions sdks/csharp/.github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
name: Test Suite

on:
push:
branches:
- staging
pull_request:

jobs:
unity-testsuite:
runs-on: ubuntu-latest
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

- name: Override NuGet packages
run: |
dotnet pack SpacetimeDB~/crates/bindings-csharp/BSATN.Runtime
dotnet pack SpacetimeDB~/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
# 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.
./tools~/write-nuget-config.sh SpacetimeDB~

- name: Run .NET tests
run: dotnet test -warnaserror

- name: Verify C# formatting
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
run: |
sed -i "s|spacetimedb *=.*|spacetimedb = \{ path = \"../../SpacetimeDB~/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
key: ${{ steps.checkout-stdb.outputs.commit }}
# Cache Rust deps even if unit tests have failed.
cache-on-failure: true
# Cache the CLI as well.
cache-all-crates: true

- name: Install SpacetimeDB CLI from the local checkout
# 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
# 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

- name: Generate client bindings
working-directory: unity-tests~/server-rust
run: bash ./generate.sh -y

- name: Check for changes
run: |
git diff --exit-code unity-tests~/client-unity/Assets/Scripts/autogen || {
echo "Error: Bindings are dirty. Please generate bindings again and commit them to this branch."
exit 1
}

- name: Check Unity meta files
uses: DeNA/unity-meta-check@v3
with:
enable_pr_comment: ${{ github.event_name == 'pull_request' }}
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Start SpacetimeDB
run: |
spacetime start &
disown

- name: Run regression tests
run: bash tools~/run-regression-tests.sh SpacetimeDB~

- name: Publish unity-tests module to SpacetimeDB
working-directory: unity-tests~/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
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
cat manifest.json

- uses: actions/cache@v3
with:
path: unity-tests~/client-unity/Library
key: Unity-${{ github.head_ref }}
restore-keys: Unity-

- name: Run Unity tests
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
githubToken: ${{ secrets.GITHUB_TOKEN }}
testMode: playmode
useHostNetwork: true
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
78 changes: 78 additions & 0 deletions sdks/csharp/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/main/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Uu]ser[Ss]ettings/

# MemoryCaptures can get excessive in size.
# They also could contain extremely sensitive data
/[Mm]emoryCaptures/

# Recordings can get excessive in size
/[Rr]ecordings/

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
/[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.unityproj
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.aab
*.unitypackage
*.app

# Crashlytics generated file
crashlytics-build.properties

# Packed Addressables
/[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin*

# Temporary auto-generated Android Assets
/[Aa]ssets/[Ss]treamingAssets/aa.meta
/[Aa]ssets/[Ss]treamingAssets/aa/*

bin~
obj~

# This is used for local paths to SpacetimeDB packages.
/nuget.config
/nuget.config.meta
.idea/
3 changes: 3 additions & 0 deletions sdks/csharp/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "SpacetimeDBCircleGame"]
path = unity-tests~
url = https://github.com/clockworklabs/SpacetimeDBCircleGame
19 changes: 19 additions & 0 deletions sdks/csharp/DEVELOP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Notes for maintainers

## `SpacetimeDB.ClientApi`

To regenerate this namespace, run the `tools~/gen-client-api.sh` or the
`tools~/gen-client-api.bat` script.

## Developing against a local clone of SpacetimeDB
When developing against a local clone of SpacetimeDB, you'll need to ensure that the packages here can find an up-to-date version of the BSATN.Codegen and BSATN.Runtime packages from SpacetimeDB.

To develop against a local clone of SpacetimeDB at `../SpacetimeDB`, run the following command:

```sh
dotnet pack ../SpacetimeDB/crates/bindings-csharp/BSATN.Runtime && ./tools~/write-nuget-config.sh ../SpacetimeDB
```

This will create a (`.gitignore`d) `nuget.config` file that uses the local build of the package, instead of the package on NuGet.

You'll need to rerun this command whenever you update `BSATN.Codegen` or `BSATN.Runtime`.
7 changes: 7 additions & 0 deletions sdks/csharp/DEVELOP.md.meta

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

6 changes: 6 additions & 0 deletions sdks/csharp/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<Project>
<PropertyGroup>
<BaseOutputPath>bin~</BaseOutputPath>
<BaseIntermediateOutputPath>obj~</BaseIntermediateOutputPath>
</PropertyGroup>
</Project>
7 changes: 7 additions & 0 deletions sdks/csharp/Directory.Build.props.meta

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

Loading
Loading