Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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

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
Expand Up @@ -94,7 +94,7 @@ public partial record TestTableTaggedEnum : SpacetimeDB.TaggedEnum<(int X, int Y
Message: Index attribute on a field applies directly to that field, so it doesn't accept the Columns parameter.,
Severity: Error,
Descriptor: {
Id: STDB0013,
Id: STDB0015,
Title: Index attribute on a field must not specify Columns,
MessageFormat: Index attribute on a field applies directly to that field, so it doesn't accept the Columns parameter.,
Category: SpacetimeDB,
Expand Down Expand Up @@ -145,7 +145,7 @@ public partial struct TestIndexIssues
Message: Could not find the specified column UnknownColumn in TestIndexIssues.,
Severity: Error,
Descriptor: {
Id: STDB0014,
Id: STDB0016,
Title: Unknown column,
MessageFormat: Could not find the specified column {0} in {1}.,
Category: SpacetimeDB,
Expand All @@ -170,7 +170,7 @@ public partial struct TestIndexIssues
Message: TestScheduleWithoutPrimaryKey is a scheduled table but doesn't have a primary key of type `ulong`.,
Severity: Error,
Descriptor: {
Id: STDB0012,
Id: STDB0014,
Title: Invalid scheduled table declaration,
MessageFormat: {0},
Category: SpacetimeDB,
Expand All @@ -195,7 +195,7 @@ public partial struct TestIndexIssues
Message: TestScheduleWithWrongPrimaryKeyType is a scheduled table but doesn't have a primary key of type `ulong`.,
Severity: Error,
Descriptor: {
Id: STDB0012,
Id: STDB0014,
Title: Invalid scheduled table declaration,
MessageFormat: {0},
Category: SpacetimeDB,
Expand All @@ -212,7 +212,7 @@ public partial struct TestIndexIssues
Message: Could not find the specified column ScheduledAt in TestScheduleIssues.,
Severity: Error,
Descriptor: {
Id: STDB0014,
Id: STDB0016,
Title: Unknown column,
MessageFormat: Could not find the specified column {0} in {1}.,
Category: SpacetimeDB,
Expand All @@ -237,7 +237,7 @@ public partial struct TestIndexIssues
Message: TestScheduleWithWrongScheduleAtType is a scheduled table but doesn't have a primary key of type `ulong`.,
Severity: Error,
Descriptor: {
Id: STDB0012,
Id: STDB0014,
Title: Invalid scheduled table declaration,
MessageFormat: {0},
Category: SpacetimeDB,
Expand All @@ -262,7 +262,7 @@ public partial struct TestScheduleIssues
Message: Could not find the specified column MissingField in TestScheduleIssues.,
Severity: Error,
Descriptor: {
Id: STDB0014,
Id: STDB0016,
Title: Unknown column,
MessageFormat: Could not find the specified column {0} in {1}.,
Category: SpacetimeDB,
Expand All @@ -287,7 +287,7 @@ public partial struct TestScheduleIssues
Message: View 'ViewDefNoPublic' must have Public = true. Views are always public in SpacetimeDB.,
Severity: Error,
Descriptor: {
Id: STDB0023,
Id: STDB0025,
Title: Views must be public,
MessageFormat: View '{0}' must have Public = true. Views are always public in SpacetimeDB.,
Category: SpacetimeDB,
Expand All @@ -304,7 +304,7 @@ public partial struct TestScheduleIssues
Message: View method ViewDefNoContext must have a first parameter of type ViewContext or AnonymousViewContext.,
Severity: Error,
Descriptor: {
Id: STDB0020,
Id: STDB0022,
Title: Views must start with ViewContext or AnonymousViewContext,
MessageFormat: View method {0} must have a first parameter of type ViewContext or AnonymousViewContext.,
Category: SpacetimeDB,
Expand All @@ -321,7 +321,7 @@ public partial struct TestScheduleIssues
Message: View method ViewDefWrongContext must have a first parameter of type ViewContext or AnonymousViewContext.,
Severity: Error,
Descriptor: {
Id: STDB0020,
Id: STDB0022,
Title: Views must start with ViewContext or AnonymousViewContext,
MessageFormat: View method {0} must have a first parameter of type ViewContext or AnonymousViewContext.,
Category: SpacetimeDB,
Expand All @@ -346,7 +346,7 @@ public partial struct TestScheduleIssues
Message: View 'ViewDefWrongReturn' must return Vec<T> or Option<T>.,
Severity: Error,
Descriptor: {
Id: STDB0022,
Id: STDB0024,
Title: Views must return Vec<T> or Option<T>,
MessageFormat: View '{0}' must return Vec<T> or Option<T>.,
Category: SpacetimeDB,
Expand Down Expand Up @@ -397,7 +397,7 @@ public partial struct TestScheduleIssues
Message: Reducer method OnReducerWithReservedPrefix starts with 'On', which is a reserved prefix.,
Severity: Error,
Descriptor: {
Id: STDB0009,
Id: STDB0010,
Title: Reducer method has a reserved name prefix,
MessageFormat: Reducer method {0} starts with '{1}', which is a reserved prefix.,
Category: SpacetimeDB,
Expand All @@ -414,7 +414,7 @@ public partial struct TestScheduleIssues
Message: Reducer method __ReducerWithReservedPrefix starts with '__', which is a reserved prefix.,
Severity: Error,
Descriptor: {
Id: STDB0009,
Id: STDB0010,
Title: Reducer method has a reserved name prefix,
MessageFormat: Reducer method {0} starts with '{1}', which is a reserved prefix.,
Category: SpacetimeDB,
Expand All @@ -427,7 +427,7 @@ public partial struct TestScheduleIssues
Message: Several reducers are assigned to the same lifecycle kind Init: Reducers.TestDuplicateReducerKind1, Reducers.TestDuplicateReducerKind2,
Severity: Error,
Descriptor: {
Id: STDB0011,
Id: STDB0013,
Title: Multiple reducers of the same kind,
MessageFormat: Several reducers are assigned to the same lifecycle kind {0}: {1},
Category: SpacetimeDB,
Expand Down Expand Up @@ -483,7 +483,7 @@ public partial struct TestScheduleIssues
Message: Field MY_FILTER is marked as [ClientVisibilityFilter] but it is not public static readonly,
Severity: Error,
Descriptor: {
Id: STDB0016,
Id: STDB0018,
Title: ClientVisibilityFilters must be public static readonly,
MessageFormat: Field {0} is marked as [ClientVisibilityFilter] but it is not public static readonly,
Category: SpacetimeDB,
Expand All @@ -500,7 +500,7 @@ public partial struct TestScheduleIssues
Message: Field MY_SECOND_FILTER is marked as [ClientVisibilityFilter] but it is not public static readonly,
Severity: Error,
Descriptor: {
Id: STDB0016,
Id: STDB0018,
Title: ClientVisibilityFilters must be public static readonly,
MessageFormat: Field {0} is marked as [ClientVisibilityFilter] but it is not public static readonly,
Category: SpacetimeDB,
Expand All @@ -517,7 +517,7 @@ public partial struct TestScheduleIssues
Message: Field MY_THIRD_FILTER is marked as ClientVisibilityFilter but it has type string which is not SpacetimeDB.Filter,
Severity: Error,
Descriptor: {
Id: STDB0015,
Id: STDB0017,
Title: ClientVisibilityFilters must be Filters,
MessageFormat: Field {0} is marked as ClientVisibilityFilter but it has type {1} which is not SpacetimeDB.Filter,
Category: SpacetimeDB,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,32 @@ Timestamp time
}
}

public sealed record ProcedureContext : Internal.IProcedureContext
{
public readonly Identity Sender;
public readonly ConnectionId? ConnectionId;
public readonly Random Rng;
public readonly Timestamp Timestamp;
public readonly AuthCtx SenderAuth;

// We need this property to be non-static for parity with client SDK.
public Identity Identity => Internal.IProcedureContext.GetIdentity();

internal ProcedureContext(
Identity identity,
ConnectionId? connectionId,
Random random,
Timestamp time
)
{
Sender = identity;
ConnectionId = connectionId;
Rng = random;
Timestamp = time;
SenderAuth = AuthCtx.BuildFromSystemTables(connectionId, identity);
}
}

public sealed record ViewContext : DbContext<Internal.LocalReadOnly>, Internal.IViewContext
{
public Identity Sender { get; }
Expand Down Expand Up @@ -1646,6 +1672,10 @@ public static void Main()
SpacetimeDB.Internal.Module.SetAnonymousViewContextConstructor(
() => new SpacetimeDB.AnonymousViewContext(new SpacetimeDB.Internal.LocalReadOnly())
);
SpacetimeDB.Internal.Module.SetProcedureContextConstructor(
(identity, connectionId, random, time) =>
new SpacetimeDB.ProcedureContext(identity, connectionId, random, time)
);
var __memoryStream = new MemoryStream();
var __writer = new BinaryWriter(__memoryStream);

Expand Down Expand Up @@ -1731,6 +1761,32 @@ SpacetimeDB.Internal.BytesSink error
error
);

[UnmanagedCallersOnly(EntryPoint = "__call_procedure__")]
public static SpacetimeDB.Internal.Errno __call_procedure__(
uint id,
ulong sender_0,
ulong sender_1,
ulong sender_2,
ulong sender_3,
ulong conn_id_0,
ulong conn_id_1,
SpacetimeDB.Timestamp timestamp,
SpacetimeDB.Internal.BytesSource args,
SpacetimeDB.Internal.BytesSink result_sink
) =>
SpacetimeDB.Internal.Module.__call_procedure__(
id,
sender_0,
sender_1,
sender_2,
sender_3,
conn_id_0,
conn_id_1,
timestamp,
args,
result_sink
);

[UnmanagedCallersOnly(EntryPoint = "__call_view__")]
public static SpacetimeDB.Internal.Errno __call_view__(
uint id,
Expand Down
21 changes: 21 additions & 0 deletions crates/bindings-csharp/Codegen/Diag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ IEnumerable<string> fullNames
method => method.ParameterList
);

public static readonly ErrorDescriptor<MethodDeclarationSyntax> ProcedureContextParam =
new(
group,
"Procedures must have a first argument of type ProcedureContext",
method =>
$"Procedure method {method.Identifier} does not have a ProcedureContext parameter.",
method => method.ParameterList
);

public static readonly ErrorDescriptor<(
MethodDeclarationSyntax method,
string prefix
Expand All @@ -92,6 +101,18 @@ string prefix
ctx => ctx.method.Identifier
);

public static readonly ErrorDescriptor<(
MethodDeclarationSyntax method,
string prefix
)> ProcedureReservedPrefix =
new(
group,
"Procedure method has a reserved name prefix",
ctx =>
$"Procedure method {ctx.method.Identifier} starts with '{ctx.prefix}', which is a reserved prefix.",
ctx => ctx.method.Identifier
);

public static readonly UnusedErrorDescriptor IncompatibleTableSchedule = new(group);

public static readonly ErrorDescriptor<(
Expand Down
Loading
Loading