Skip to content

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//HintName: FFI.cs
//HintName: FFI.cs
// <auto-generated />
#nullable enable
// The runtime already defines SpacetimeDB.Internal.LocalReadOnly in Runtime\Internal\Module.cs as an empty partial type.
Expand All @@ -17,7 +17,6 @@ namespace SpacetimeDB
{
public sealed record ReducerContext : DbContext<Local>, Internal.IReducerContext
{
public readonly Identity Sender;
public readonly ConnectionId? ConnectionId;
public readonly Random Rng;
public readonly Timestamp Timestamp;
Expand All @@ -29,6 +28,8 @@ public sealed record ReducerContext : DbContext<Local>, Internal.IReducerContext
// We need this property to be non-static for parity with client SDK.
public Identity Identity => Internal.IReducerContext.GetIdentity();

private readonly Identity _sender;

internal ReducerContext(
Identity identity,
ConnectionId? connectionId,
Expand All @@ -37,14 +38,19 @@ internal ReducerContext(
AuthCtx? senderAuth = null
)
{
Sender = identity;
_sender = identity;
ConnectionId = connectionId;
Rng = random;
Timestamp = time;
SenderAuth = senderAuth ?? AuthCtx.BuildFromSystemTables(connectionId, identity);
CounterUuid = 0;
}

/// <summary>
/// The identity of the client that invoked the reducer.
/// </summary>
public Identity Sender() => _sender;

/// <summary>
/// Create a new random <see cref="Uuid"/> `v4` using the built-in RNG.
/// </summary>
Expand Down Expand Up @@ -199,13 +205,18 @@ public sealed class Local : global::SpacetimeDB.LocalBase

public sealed record ViewContext : DbContext<Internal.LocalReadOnly>, Internal.IViewContext
{
public Identity Sender { get; }
private readonly Identity _sender;

internal ViewContext(Identity sender, Internal.LocalReadOnly db)
: base(db)
{
Sender = sender;
_sender = sender;
}

/// <summary>
/// The identity of the client that invoked the view.
/// </summary>
public Identity Sender() => _sender;
}

public sealed record AnonymousViewContext
Expand Down
20 changes: 16 additions & 4 deletions crates/bindings-csharp/Codegen/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,6 @@ public void Initialize(IncrementalGeneratorInitializationContext context)

namespace SpacetimeDB {
public sealed record ReducerContext : DbContext<Local>, Internal.IReducerContext {
public readonly Identity Sender;
public readonly ConnectionId? ConnectionId;
public readonly Random Rng;
public readonly Timestamp Timestamp;
Expand All @@ -1753,16 +1752,24 @@ public sealed record ReducerContext : DbContext<Local>, Internal.IReducerContext
// We need this property to be non-static for parity with client SDK.
public Identity Identity => Internal.IReducerContext.GetIdentity();

private readonly Identity _sender;

internal ReducerContext(Identity identity, ConnectionId? connectionId, Random random,
Timestamp time, AuthCtx? senderAuth = null)
{
Sender = identity;
_sender = identity;
ConnectionId = connectionId;
Rng = random;
Timestamp = time;
SenderAuth = senderAuth ?? AuthCtx.BuildFromSystemTables(connectionId, identity);
CounterUuid = 0;
}

/// <summary>
/// The identity of the client that invoked the reducer.
/// </summary>
public Identity Sender() => _sender;

/// <summary>
/// Create a new random <see cref="Uuid"/> `v4` using the built-in RNG.
/// </summary>
Expand Down Expand Up @@ -1897,13 +1904,18 @@ public sealed class Local : global::SpacetimeDB.LocalBase {

public sealed record ViewContext : DbContext<Internal.LocalReadOnly>, Internal.IViewContext
{
public Identity Sender { get; }
private readonly Identity _sender;

internal ViewContext(Identity sender, Internal.LocalReadOnly db)
: base(db)
{
Sender = sender;
_sender = sender;
}

/// <summary>
/// The identity of the client that invoked the view.
/// </summary>
public Identity Sender() => _sender;
}

public sealed record AnonymousViewContext : DbContext<Internal.LocalReadOnly>, Internal.IAnonymousViewContext
Expand Down
7 changes: 5 additions & 2 deletions crates/bindings-csharp/Runtime/Internal/TxContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ public sealed class TxContext(
Random rng
)
{
private readonly Identity _sender = sender;

public Local Db { get; } = db;
public Identity Sender { get; } = sender;
public ConnectionId? ConnectionId { get; } = connectionId;
public Timestamp Timestamp { get; } = timestamp;
public AuthCtx SenderAuth { get; } = senderAuth;
public Random Rng { get; } = rng;

public Identity Sender() => _sender;

public TxContext WithTimestamp(Timestamp ts) =>
new(Db, Sender, ConnectionId, ts, SenderAuth, Rng);
new(Db, _sender, ConnectionId, ts, SenderAuth, Rng);
}
10 changes: 7 additions & 3 deletions crates/bindings-csharp/Runtime/ProcedureContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
Timestamp time
) : Internal.IInternalProcedureContext
{
private readonly Identity _sender = sender;

public Identity Sender() => _sender;

public static Identity Identity => Internal.IProcedureContext.GetIdentity();
public Identity Sender { get; } = sender;
public ConnectionId? ConnectionId { get; } = connectionId;
public Random Rng { get; } = random;
public Timestamp Timestamp { get; private set; } = time;
Expand Down Expand Up @@ -47,7 +50,7 @@
txContext?.WithTimestamp(timestamp)
?? new Internal.TxContext(
CreateLocal(),
Sender,
_sender,
ConnectionId,
timestamp,
SenderAuth,
Expand Down Expand Up @@ -108,14 +111,14 @@
}

// Private transaction management methods (Rust-like encapsulation)
private long StartMutTx()

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Windows)

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / csharp-testsuite

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Linux)

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Test Suite

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Python Legacy) (Linux)

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Python Legacy) (Windows)

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 114 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / unity-testsuite

Member 'StartMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)
{
var status = Internal.FFI.procedure_start_mut_tx(out var micros);
Internal.FFI.ErrnoHelpers.ThrowIfError(status);
return micros;
}

private void CommitMutTx()

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Windows)

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / csharp-testsuite

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Linux)

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Test Suite

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Python Legacy) (Linux)

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / Smoketests (Python Legacy) (Windows)

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)

Check warning on line 121 in crates/bindings-csharp/Runtime/ProcedureContext.cs

View workflow job for this annotation

GitHub Actions / unity-testsuite

Member 'CommitMutTx' does not access instance data and can be marked as static (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1822)
{
var status = Internal.FFI.procedure_commit_mut_tx();
Internal.FFI.ErrnoHelpers.ThrowIfError(status);
Expand Down Expand Up @@ -229,8 +232,9 @@

internal void Refresh(Internal.TxContext inner) => Inner = inner;

public Identity Sender() => Inner.Sender();

public LocalBase Db => (LocalBase)Inner.Db;
public Identity Sender => Inner.Sender;
public ConnectionId? ConnectionId => Inner.ConnectionId;
public Timestamp Timestamp => Inner.Timestamp;
public AuthCtx SenderAuth => Inner.SenderAuth;
Expand Down
2 changes: 1 addition & 1 deletion crates/bindings-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ pub mod raw {
/// would be where you would initialize the interepreter and load the user module into it.
fn __setup__() -> Result;
/// Required. Runs after `__setup__`; returns all the exports for the module.
fn __describe_module__() -> Encoded<ModuleDef>;
fn __describe_module_v10__() -> Encoded<ModuleDef>;
/// Required. id is an index into the `ModuleDef.reducers` returned from `__describe_module__`.
/// args is a bsatn-encoded product value defined by the schema at `reducers[id]`.
fn __call_reducer__(
Expand Down

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

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

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

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

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

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

Loading
Loading