C# implementation of Transactions for Procedures#3809
Conversation
…ession test server
gefjon
left a comment
There was a problem hiding this comment.
I'd like to see a more in-depth PR description which goes into detail on your design and implementation choices. Especially in big PRs like this, there's a burden on the author to both keep the changes as contained and laser-focused as possible, and also to proactively explain to reviewers what's going on in the diff. Anywhere I've left a comment asking for reasoning, that's the kind of thing that should be in your PR description proactively.
…alProcedureContext
…o ProcedureContextBase
…b.com/clockworklabs/SpacetimeDB into rekhoff/csharp-procedure-transactions
…b.com/clockworklabs/SpacetimeDB into rekhoff/csharp-procedure-transactions
JasonAtClockwork
left a comment
There was a problem hiding this comment.
Looks solid now, I've run the regression tests and walked through the changes. One small nit would be to add Log.Debug() for all successful tests but I think we want to rework the test runner soon anyhow.
gefjon
left a comment
There was a problem hiding this comment.
This looks great, thanks!
Description of Changes
Implements the C# equivalent of #3638
This implement uses inheritance, where abstract base classes (like
ProcedureContextBaseinProcedureContext.cs) store the core of the implementation, and then generated wrappers (likeProcedureContextin the generated FFI.cs file) inherit from them.For error handling, we work like Rust's implementation of
Result<T,E>but we requirewhere E : Exceptionbecause of how exceptions work in C#. Transaction-level failures come back as aTxOutcomeand user errors should follow theResult<T,E>pattern. In this implementation, we haveUnwrapOrThrow()throws exceptions directly because of C#'s error handling pattern.Unlike the Rust implementation's direct
Resultpropagation, we are using anAbortGuardpattern (inProcedureContext.cs) for exception handling, which usesIDisposablefor 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:
This change includes a number of tests added to the
sdks/csharp/examples~/regression-tests/'sserverandclientto validate the behavior of the changes.serverchanges 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