Commit Graph

64 Commits

Author SHA1 Message Date
rekhoff 39f01289e5 C# implementation of Transactions for Procedures (#3809)
# Description of Changes

Implements the C# equivalent of #3638

This implement uses inheritance, where abstract base classes (like
`ProcedureContextBase` in `ProcedureContext.cs`) store the core of the
implementation, and then generated wrappers (like `ProcedureContext` in
the generated FFI.cs file) inherit from them.

For error handling, we work like Rust's implementation of `Result<T,E>`
but we require `where E : Exception` because of how exceptions work in
C#. Transaction-level failures come back as a `TxOutcome` and user
errors should follow the `Result<T,E>` pattern. In this implementation,
we have `UnwrapOrThrow()` throws exceptions directly because of C#'s
error handling pattern.

Unlike the Rust implementation's direct `Result` propagation, we are
using an `AbortGuard` pattern (in `ProcedureContext.cs`) for exception
handling, which uses `IDisposable` for automatic cleanup.

Most changes should have fairly similar Rust-equivalents beyond that.
For module authors, the changes here allow for the transation logic to
work like:
```csharp
ctx.TryWithTx<ResultType, Exception>(tx => {
    // transaction logic
    return Result<ResultType, Exception>.Ok(result);
});
```
This change includes a number of tests added to the
`sdks/csharp/examples~/regression-tests/`'s `server` and `client` to
validate the behavior of the changes. `server` changes provide further
usage examples for module authors.

# API and ABI breaking changes

Should not be a breaking change

# Expected complexity level and risk

2

# Testing

- [x] Created Regression Tests that show transitions in procedures
working in various ways, all of which pass.
2025-12-18 18:41:47 +00:00
John Detter eb5000895d Bump versions to 1.11.1 (#3901)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

- Bump version numbers to `1.11.1`

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

1

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

- [x] Verified that the license has been updated
- [x] `spacetime --version` on this commit is correct

There is also a corresponding private PR.
2025-12-18 16:35:50 +00:00
Zeke Foppa 141048cdd8 Bump versions to 1.11.0 (#3808)
# Description of Changes

Bumping versions to 1.11.0 in preparation for an upcoming release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing

- [x] Existing CI passes

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-12-02 22:45:29 +00:00
John Detter 0590f7022d Upgrade to version 1.10.0 (#3769)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

This upgrades the SpacetimeDB version to 1.10.0.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

1

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

This is just a version bump - not tested.
2025-11-26 17:55:26 +00:00
John Detter 77886a50a9 Upgrade to version 1.9.0 (#3709)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

Upgrade to version 1.9.0.

# API and ABI breaking changes

None - just a version upgrade.

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

1

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] I verified that the license has been updated
- [x] The version number looks correct (1.9.0)

---------

Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-11-22 01:22:40 +00:00
rekhoff cb35104c0f Export __call_view__ in C# (#3691)
# Description of Changes

1. Updates the Replication Tests in
`sdks/csharp/examples~/regression-tests` to include better coverage of
Views
2. Added missing linkage for __call_view__ and __call_view_anon__
3. Updated *ViewDispatcher Invoke to transform BSATN.ValueOption<> into
BSATN.List<>
4. Fixed issues with the indexing of views to match correctly during
__call_view__ and __call_view_anon__

# API and ABI breaking changes

No

# Expected complexity level and risk

2

# Testing

- [x] Running `run-regression-tests.sh` passes.

---------

Signed-off-by: rekhoff <r.ekhoff@clockworklabs.io>
Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: Jason Larabie <jason@clockworklabs.io>
Co-authored-by: John Detter <4099508+jdetter@users.noreply.github.com>
Co-authored-by: joshua-spacetime <josh@clockworklabs.io>
2025-11-20 17:17:37 +00:00
John Detter 6bd557254d Upgrade to version 1.8.0 (#3633)
# Description of Changes

<!-- Please describe your change, mention any related tickets, and so on
here. -->

- This upgrades the versions of all SDKs, the CLI, etc. to 1.8.0

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

None

# Expected complexity level and risk

<!--
How complicated do you think these changes are? Grade on a scale from 1
to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex
change.

This complexity rating applies not only to the complexity apparent in
the diff,
but also to its interactions with existing and future code.

If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning
ways. -->

1

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] I verified that all versions seem to be updated including the BSL
license update <!-- maybe a test you want to do -->

We have 1 `1.7.0` that didn't get upgraded automatically because it is
part of the module bindings for a template:

```
crates/cli/.templates/parent_parent_crates_bindings-typescript_examples_quickstart-chat/src/module_bindings/index.ts:    cliVersion: '1.7.0',
```

A case could possibly be made for bumping the template but it shouldn't
cause any issues as the module bindings directory should just get
regenerated by the user. @cloutiertyler should we be bumping module
bindings for templates when we upgrade versions?

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-11-12 12:21:09 +00:00
Zeke Foppa 34b4a2b899 Bump versions to 1.7.0 (#3550)
# Description of Changes

Bump versions to 1.7.0 in preparation for the release.

# API and ABI breaking changes

<!-- If this is an API or ABI breaking change, please apply the
corresponding GitHub label. -->

# Expected complexity level and risk

1

# Testing

- [x] CI passes

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-11-04 19:26:51 +00:00
Zeke Foppa d4837c37ab Bump versions to 1.6.0 (#3413)
# Description of Changes

Bumping versions to 1.6.0 in preparation for upcoming release.

# API and ABI breaking changes

None

# Expected complexity level and risk

1
# Testing

- [x] Existing CI only

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-10-16 01:26:35 +00:00
Zeke Foppa ea61c949e1 Bump versions to 1.5.0, update DLLs, and regenerate files (#3310)
# Description of Changes

Bumping versions to 1.5.0 since we have merged some new features (at the
very least, https://github.com/clockworklabs/SpacetimeDB/pull/3292)

# API and ABI breaking changes

None

# Expected complexity level and risk

1

# Testing
None

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-09-30 18:18:47 +00:00
Zeke Foppa 32559048e6 Bump remaining versions to 1.4.0 (#3267)
# Description of Changes

Bumping remaining files so that everything is at 1.4.0.

# API and ABI breaking changes

None.

# Expected complexity level and risk

1

# Testing

None

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-09-23 00:35:19 +00:00
Wes Sleeman e715c80a17 TimeSpan-Style TimeDuration Constructors in C# Bindings (#2778)
# Description of Changes

This change adds the following `System.TimeSpan`-style static
construction methods to `SpacetimeDB.TimeDuration`:
* `static TimeDuration FromMilliseconds(double milliseconds)`
* `static TimeDuration FromSeconds(double seconds)`
* `static TimeDuration FromMinutes(double minutes)`
* `static TimeDuration FromHours(double hours)`
* `static TimeDuration FromDays(double days)`

These mirror the equivalently named static methods on `System.TimeSpan`
and dramatically improve usability and familiarity for experienced C#
users with no more overhead than the user performing the multiplication
themselves.

Wish I'd thought to do this before v1.1.2 got released. Ah well.

# API and ABI breaking changes

None. Convenience methods added in bindings only.

# Expected complexity level and risk

1 (potentially up to a low 2 if cleanup is desired elsewhere in the
bindings to leverage these new methods).

# Testing

<!-- Describe any testing you've done, and any testing you'd like your
reviewers to do,
so that you're confident that all the changes work as expected! -->

- [x] Ensure the changes build. <!-- maybe a test you want to do -->
- [ ] New contributor check! Review to make sure repo style & substance
standards are complied with. <!-- maybe a test you want a reviewer to
do, so they can check it off when they're satisfied. -->
2025-08-15 09:27:36 -07:00
Zeke Foppa e107144998 Bump versions to 1.3.0 (#3005)
# Description of Changes

Bumped all versions to 1.3.0 in preparation for an upcoming minor
release.

# API and ABI breaking changes

No breaking changes.

# Expected complexity level and risk

1

# Testing

None

---------

Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-07-30 19:16:16 +00:00
Zeke Foppa 67703b1fee Bump C# versions to 1.2.1 (#2890)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-06-23 17:34:38 +00:00
james gilles 971ae75b5d Improve serialization speed of enums without data in C# (#2762) 2025-06-20 17:38:29 +00:00
Zeke Foppa 380acf14c8 Bump versions to 1.2.0 (#2837)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-06-06 16:17:24 +00:00
Zeke Foppa ec26f526ed Bump C# versions (#2774)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-05-22 17:47:50 +00:00
james gilles 0d419afbfa Reduce reflection use in generated C# code (#2725) 2025-05-14 18:36:50 +00:00
james gilles 7dddee91eb Reduce allocations in C# when deserializing lists and arrays (#2688) 2025-05-05 17:28:53 +00:00
joshua-spacetime b1002f70a2 Avoid reflection when validating enums (#2676) 2025-04-29 22:29:31 +00:00
Zeke Foppa 3083c1b83e Bump versions to 1.1.1 (#2658)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-04-22 19:20:17 +00:00
Phoebe Goldman 62818e9c7b Various methods and trait impls for time arithmetic (#2502) 2025-04-03 18:06:28 +00:00
Mario Montoya 4ade692700 Update formatting of timestamps and identities in PsqlFormatter (#2486) 2025-04-02 16:53:27 +00:00
Zeke Foppa c3c0d92fbe Bump versions to 1.1.0 (#2518)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-03-27 23:37:38 +00:00
james gilles f5e4663cb5 Implement IEquatable<Self> for all [SpacetimeDB.Type]s (#2396) 2025-03-12 18:59:34 +00:00
Zeke Foppa 8930e78f97 Bump versions to 1.0.1 (#2431)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-03-11 18:43:48 +00:00
rekhoff 7947a593ff Implements IComparable for Identity and ConnectionId (#2354) 2025-03-07 01:06:41 +00:00
Zeke Foppa 20f4bfbd21 Bump Rust and C# package versions to 1.0.0 (#2283)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
Co-authored-by: John Detter <no-reply@boppygames.gg>
2025-02-28 20:13:07 +00:00
james gilles 5159c79be0 Implement IComparable for Timestamp (#2239) 2025-02-10 21:34:36 +00:00
Phoebe Goldman aedc601145 Rename Address to ConnectionId (#2220)
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Tyler Cloutier <cloutiertyler@users.noreply.github.com>
2025-02-10 00:40:16 +00:00
Phoebe Goldman 91327d585e Make Timestamp a special SATS type (#1836)
Signed-off-by: Phoebe Goldman <phoebe@goldman-tribe.org>
Co-authored-by: James Gilles <jameshgilles@gmail.com>
Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
2025-02-07 18:17:53 +00:00
Zeke Foppa 20ab595b29 Bump version to 1.0.0-rc4 (#2177)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-01-27 22:54:36 +00:00
james gilles 988ec0cdd4 Fix ScheduleAt in C# (#2163) 2025-01-23 19:59:38 +00:00
Tyler Cloutier 6f807e273c Updated version to 1.0.0-rc3 (#2059)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2025-01-08 18:17:10 +00:00
Ingvar Stepanyan 40faad6e2e Implement ctx.Identity for C# (#2091) 2025-01-07 20:45:27 +00:00
Ingvar Stepanyan 78b48c9a98 Reduce noisy C# compilation errors (#2067) 2024-12-30 23:48:50 +00:00
Ingvar Stepanyan 08a3f3210b Migrate C# ModuleDef to V9 (#1670) 2024-12-16 21:49:42 +00:00
james gilles b9b36d5de1 Fix declaration order of ScheduleAt in C# (#2007)
Co-authored-by: Tyler Cloutier <cloutiertyler@aol.com>
2024-12-10 05:07:48 +00:00
james gilles dee297adfb C# endianness fixes (#1964) 2024-11-20 18:23:30 +00:00
Zeke Foppa 5bf5b2ba09 Bump C# versions to -hotfix1 (#1984)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-11-12 04:25:10 +00:00
Ingvar Stepanyan bc79f93e29 Hide "internal" datetime representation types (#1921) 2024-10-30 16:49:51 +00:00
Zeke Foppa 7de743d44d Bump C# bindings to 1.0.0 (#1913)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-10-29 00:23:49 +00:00
Ingvar Stepanyan e595b11761 NFC: Remove obsolete BytesWrapper (#1896)
Signed-off-by: Ingvar Stepanyan <me@rreverser.com>
2024-10-28 15:45:24 +00:00
Mazdak Farrokhzad 263511e15b Redefine Address as U128 + Identity and Hash as U256 (#1616)
Co-authored-by: James Gilles <jameshgilles@gmail.com>
2024-10-18 20:00:21 +00:00
Mazdak Farrokhzad 06cc688885 No Maps for you! (#1770) 2024-10-15 22:34:13 +00:00
Jeremie Pelletier 02b70d5c94 c# client generate (#1707) 2024-10-04 04:12:15 +00:00
Jeremie Pelletier 32349062ec Jeremie/cs module (#1719) 2024-09-27 11:23:50 +00:00
Ingvar Stepanyan 214eb7e047 NFC: enforce more C# code style + enable it in Visual Studio (#1687) 2024-09-16 19:29:33 +00:00
Ingvar Stepanyan 68e356519e C#: split table codegen logic from type codegen logic (#1573)
Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
2024-09-05 18:00:40 +00:00
Ingvar Stepanyan b4c7c89239 NFC: use record for BigInt equality and hash (#1633) 2024-08-26 10:10:49 +00:00