Commit Graph

18 Commits

Author SHA1 Message Date
Jason Larabie 78c28d4936 Add C# client SDK procedures (#3666)
# Description of Changes

Closes: #3533 
Updated the C# SDK to handle procedures and procedure callbacks in a
similar fashion to the Rust client as well as added the codegen to
support it.

# API and ABI breaking changes

N/A

# Expected complexity level and risk

2 - This adds a new testing frame that should be removed once procedures
are handled with C# module bindings

# Testing

Added /sdks/csharp/examples~/regression-tests/procedure-client to match
modules/sdk-test-procedure which we can roll into the standard
regression-tests once C# supports the procedure attribute.

- [x] Add C# client test of sdk-test-procedure

---------

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
2025-11-21 19:39:21 +00:00
Piotr Sarnacki b2cee93b52 New command: spacetime dev (#3469)
# Description of Changes

This PR implements a new command for the CLI: `spacetime dev`. If run
from outside of a project directory, it will call `init` in interactive
mode to allow user to create a project. If run from a project directory,
it will ask for a module to conect to and it will:

* subscribe to logs
* observe files in the `spacetimedb` directory and automatically publish
to SpacetimeDB

One caveat is that instead of reusing the `logs` code I did some
repetition cause currently the logs code acquires a lock that lives
through await points. It is fixable, but due to limited time I decided
to go with a bit of code duplication. It shouldn't be very hard to fix
later, though.

---------

Signed-off-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Signed-off-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: = <cloutiertyler@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2025-10-30 21:04:29 +00:00
Zeke Foppa 1aa4084762 CI - Clean up several scripts and call sites related to codegen (#3363)
# Description of Changes

* Small cleanups in `tools/check-diff.sh`
* Use `tools/check-diff.sh` wherever appropriate
* Simplify the `sdks/csharp/tools~/gen-*.sh` files after the repo merge

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

- [x] CI still passes

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-10 14:23:18 +00:00
rekhoff a546bc8961 Rekhoff/csharp default field values (#3235)
# Description of Changes

This is the implementation of issue #3191. This adds a Default attribute
to C# module fields.

**Note**: In C#, attribute arguments must be compile-time constants,
which means you can't directly use non-constant expressions like new
expressions, method calls, or dynamic values in attribute constructors.
(Ref:
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/attributes#2324-attribute-parameter-types)

For this reason, these default values are limited to primitive types,
enums, and strings.
This includes (shown as `C# Type` (`BSATN type`):

* `bool` (`Bool`)
* `sbyte` (`I8`)
* `byte` (`U8`)
* `short` (`I16`)
* `ushort` (`U16`)
* `int` (`I32`)
* `unit` (`U32`)
* `long` (`I64`)
* `ulong` (`U64`)
* `float` (`F32`)
* `double` (`F64`)
* `enum` (`Enum`)
* `string` (`String`)
* `null` (`RefOption`) <- Nullable type

Because of C# limitations, for nullable and complex data types, such as
a struct, can take use `[Default(null)]` to populate values with null
defaults. This allows things like structs to workaround the non-constant
expressions in attribute constructors limitation by allowing these
complex types to still be able to be added as new column tables.

The `int` type can also be in the form of Hex or Binary literals, such
as `[Default(0x2A)]` or `[Default(0b00101010)]`

Both Decimal (like `[Default(3.14m)]`) and Char (like `[Default('A')]`)
are unsupported types in BSATN and will still return `BSATN0001` errors.

# API and ABI breaking changes

Not API breaking.
This change only adds the `[Default(value)]` attribute logic.
Using the `[Default(value)]` attribute with older versions SpacetimeDB
C# modules will result in an error.

# Expected complexity level and risk

2

# Testing

Local testing of this requires use of CLI changes in #3278 

- [x] Regression test of functionality added.
2025-10-06 16:56:37 +00:00
Zeke Foppa 7aae091d85 C# tests - update snapshots (#3321)
# Description of Changes

I chose to regenerate all of the bindings in
https://github.com/clockworklabs/SpacetimeDB/pull/3310, but that caused
the snapshots to change. This PR follows up to update them.

I also updated the outdated script `tools~/gen-quickstart-chat.sh`
(which was generating from a different module than the CI was), and
updated the CI to use it instead of manually running a similar command.

# API and ABI breaking changes

Test-only changes.

# Expected complexity level and risk

1

# Testing

- [x] unity-testsuite passes on this PR (which it does not on `master`).

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-01 04:01:46 +00:00
Zeke Foppa 6c419ccaa5 Add tools~/upgrade-version.py (#335)
## 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>
2025-06-25 11:57:53 -04:00
james gilles c813fb321d Fix list equals (#316)
Update DLLs and generated code for SpacetimeDB 74ad4a14c
2025-05-12 20:55:15 +00:00
james gilles b6f8362b75 Implement OnUnhandledReducerError (#295)
## Description of Changes
SDK side of https://github.com/clockworklabs/SpacetimeDB/pull/2636
Addresses
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/issues/281

## API

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

## Requires SpacetimeDB PRs
https://github.com/clockworklabs/SpacetimeDB/pull/2636

## 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: jgilles/on-unhandled-reducer-error

## Testing

- [ ] Add a test that this works to the regression-tests example module
2025-04-23 13:50:53 -07:00
james gilles 3543132c7d Fix for unsubscribe bug + regression tests (#264)
## Description of Changes

This PR fixes one issue and adds regression tests for it, plus another
issue. These regression tests are run on CI. You can also run them
locally -- run a local spacetime instance and then
`tools~/run-regression-tests.sh ../SpacetimeDB`).

### Issue 1: Unsubscribe is non-functional

See
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/issues/279.
This was a coding mistake made during the rush to 1.0. It was easily
fixed.

### Issue 2: Indexes not tracking deletes

This was recently discovered by the BitCraft team.

The problem was introduced in
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/commit/cefc727b7693fe97e3dd848fef2bb17bf20c8be6
which introduced `RemoteTableHandle<EventContext,
Row>.IndexBase<Column>`. This class stores a `Dictionary<Column,
List<Row>>` to allow fast filtering. It relies on `List<Row>.Remove` to
remove elements from a list when a row delete is received.
`List<Row>.Remove` relies on `Row.Equals` to determine when elements are
equal.

`Row.Equals` formerly was not implemented for `[SpacetimeDB.Type]`s or
for generated Row types. So, this didn't work.

Now it does: it was fixed by
https://github.com/clockworklabs/SpacetimeDB/pull/239 . So all this PR
does to address this issue is add a regression test.

## API

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

The interface IDbConnection was changed; however, this changed part of
the interface is `internal`, so this should be entirely invisible to
users.

## Requires SpacetimeDB PRs
https://github.com/clockworklabs/SpacetimeDB/pull/239 (merged)

## 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*

- [x] Added a repro for both issues
- [x] Added the repro to CI
- [x] Fixed both issues
2025-03-28 20:15:51 +00:00
james gilles 498b25f825 Emit Event.UnknownTransaction rather than throwing on unknown reducer (#244)
## Description of Changes
as described

## API

no breaks

## Requires SpacetimeDB PRs
https://github.com/clockworklabs/SpacetimeDB/pull/2241

## Testsuite

SpacetimeDB branch name: jgilles/unknown_reducer

## Testing

see SpacetimeDB PR
2025-02-11 13:21:06 -05:00
Phoebe Goldman 96d52c1a7b Rename Address to ConnectionId (#239)
## Description of Changes

Companion to [Rename `Address` to
`ConnectionId`](https://github.com/clockworklabs/SpacetimeDB/pull/2220).
See that PR's description for more.

Like all the SDKs, this PR does not change the SDK's behavior; the SDK
still generates a connection ID locally and passes it through the HTTP
API. This is not exposed to users, and can be changed in a follow-up.

Also, use `/usr/bin/env bash` instead of `/bin/bash` in tools, for
portability reasons.

## API

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

`Address` is renamed to `ConnectionId`.

## Requires SpacetimeDB PRs

- https://github.com/clockworklabs/SpacetimeDB/pull/2220
- 
## 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: phoebe/rename-address-to-connection-id

## Testing

- [x] Pretty much just automated testing.
- [x] @kazimuth will need to update and run Blackholio.

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
2025-02-10 00:29:18 +00:00
james gilles b4aa612239 Make Timestamp and TimeDuration special types (#233)
## Description of Changes

C# part of https://github.com/clockworklabs/SpacetimeDB/pull/1836
Needs to be rebased onto
https://github.com/clockworklabs/com.clockworklabs.spacetimedbsdk/pull/220
once that is merged.

## API

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

ScheduleAt is now constructed in slightly different ways.

## 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: phoebe/timestamp-special-type

## Testing
Will need an update to blackholio as well.
2025-02-07 14:17:45 -05:00
Ingvar Stepanyan cefc727b76 Rewrite C# codegen to the new Lang infra + fixes (#220)
## Description of Changes

This is the companion PR for
https://github.com/clockworklabs/SpacetimeDB/pull/2184, please see the
other PR for full description.

On the client side main changes are:

- Regenerate .NET and Unity test client bindings and test snapshot.
- Remove `IDatabaseRow` since V9 multi-tables splits data types from
actual table definitions, so those "table data types" are no longer
special. Just using `IStructuralReadWrite` in its place now.
- Add base index classes as mentioned in the other PR.
- As a sub-improvement, the non-unique index class actually does
indexing instead of iterating over the entire table like we did before.
- Remove internal-but-not-really `InternalInvokeValueDeleted` and
`InternalInvokeValueInserted` methods in favour of private events.

## API

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

Removes some technically-visible but internal APIs.

## Requires SpacetimeDB PRs
https://github.com/clockworklabs/SpacetimeDB/pull/2184

## 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: ingvar/csharp-new-codegen

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

- [x] Manually tested Blackholio

---------

Co-authored-by: James Gilles <jameshgilles@gmail.com>
2025-02-05 16:48:15 -05:00
Ingvar Stepanyan 3d530ee248 Upgrade to new regenerated client-api bindings (#218)
## Description of Changes

Looks like client API bindings haven't been regenerated in a while, and
this is a necessary precursor to the new subscription work. This PR
fixes the generation script, regenerates the bindings and updates
affected code.

## 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: v1.0.0-rc3

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

- [x] Ran regular `dotnet test`.
- [x] Checked Unity tests via CI.
2025-01-16 17:29:27 +00:00
Mazdak Farrokhzad 2ad31d65b4 Companion to SpacetimeDB#1812 (light tx, C#) (#170)
## Description of Changes

Adds C# sdk support for
https://github.com/clockworklabs/SpacetimeDB/pull/1812.

## Requires SpacetimeDB PRs

- https://github.com/clockworklabs/SpacetimeDB/pull/1812

## Testsuite

SpacetimeDB branch name: centril/websocket-light

---------

Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
2024-11-04 17:46:42 +01:00
Zeke Foppa b96f1a6cd5 Fix gen-client-api scripts for new CLI API (#151)
## Description of Changes
The CLI arg changes in
https://github.com/clockworklabs/SpacetimeDB/pull/1741 broke these
scripts. This PR incorporates the param renames.

## API
No changes to how things are used.

## Requires SpacetimeDB PRs
I guess https://github.com/clockworklabs/SpacetimeDB/pull/1741

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-10-03 09:48:54 -07:00
Zeke Foppa affa2af7db Add script to generate nuget.config (#115)
## Description of Changes
Adds a utility script to generate `nuget.config` given a path to the
`SpacetimeDB` repo.

## API
No

## Requires SpacetimeDB PRs
None

## Testing
- [x] CI
- [x] Ran locally

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-10-03 13:03:29 +01:00
SteveGibson 589d40480f Logging API (#132)
## Description of Changes
*Describe what has been changed, any new features or bug fixes*

Changed logging based on [this
proposal](https://github.com/clockworklabs/SpacetimeDBPrivate/pull/981)

## API

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

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

Logging interface is different now. `Logger` has been renamed to `Log`,
and its methods have been renamed as well (ex. `Logger.LogError` is now
`Log.Error`)


## Requires SpacetimeDB PRs
*List any PRs here that are required for this SDK change to work*

---------

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Jeremie Pelletier <jeremiep@gmail.com>
Co-authored-by: Steve Boytsun <steve@clockwokrlabs.io>
Co-authored-by: Ingvar Stepanyan <me@rreverser.com>
2024-09-23 13:52:50 -04:00