From 0b6c0f09c4654fb428d7d498dcf067bea14848c0 Mon Sep 17 00:00:00 2001 From: Ingvar Stepanyan Date: Fri, 6 Sep 2024 17:28:54 +0100 Subject: [PATCH] Auto-generate C# ModuleDef bindings from Rust --- .gitattributes | 1 + Cargo.lock | 1 + crates/bindings-csharp/BSATN.Codegen/Type.cs | 16 +- .../bindings-csharp/Codegen.Tests/TestInit.cs | 5 +- .../server/snapshots/Module#FFI.verified.cs | 59 ++---- .../snapshots/Module#PrivateTable.verified.cs | 19 +- .../snapshots/Module#PublicTable.verified.cs | 196 +++++------------- ...Module#Timers.SendMessageTimer.verified.cs | 42 ++-- crates/bindings-csharp/Codegen/Module.cs | 59 ++++-- .../Runtime/Internal/Autogen/IndexType.cs | 18 ++ .../Runtime/Internal/Autogen/Lifecycle.cs | 19 ++ .../Internal/Autogen/MiscModuleExport.cs | 17 ++ .../Internal/Autogen/RawColumnDefV8.cs | 38 ++++ .../Internal/Autogen/RawConstraintDefV8.cs | 43 ++++ .../Internal/Autogen/RawIndexAlgorithm.cs | 17 ++ .../Runtime/Internal/Autogen/RawIndexDefV8.cs | 48 +++++ .../Runtime/Internal/Autogen/RawIndexDefV9.cs | 43 ++++ .../Internal/Autogen/RawMiscModuleExportV9.cs | 16 ++ .../Runtime/Internal/Autogen/RawModuleDef.cs | 17 ++ .../Internal/Autogen/RawModuleDefV8.cs | 48 +++++ .../Internal/Autogen/RawModuleDefV9.cs | 53 +++++ .../Internal/Autogen/RawReducerDefV9.cs | 43 ++++ .../Internal/Autogen/RawScheduleDefV9.cs | 38 ++++ .../Internal/Autogen/RawScopedTypeNameV9.cs | 38 ++++ .../Internal/Autogen/RawSequenceDefV8.cs | 63 ++++++ .../Internal/Autogen/RawSequenceDefV9.cs | 58 ++++++ .../Runtime/Internal/Autogen/RawTableDefV8.cs | 68 ++++++ .../Runtime/Internal/Autogen/RawTableDefV9.cs | 73 +++++++ .../Runtime/Internal/Autogen/RawTypeDefV9.cs | 43 ++++ .../Autogen/RawUniqueConstraintDefV9.cs | 38 ++++ .../Runtime/Internal/Autogen/ReducerDef.cs | 38 ++++ .../Runtime/Internal/Autogen/TableAccess.cs | 18 ++ .../Runtime/Internal/Autogen/TableDesc.cs | 38 ++++ .../Runtime/Internal/Autogen/TableType.cs | 18 ++ .../Runtime/Internal/Autogen/TypeAlias.cs | 38 ++++ .../Runtime/Internal/Autogen/Typespace.cs | 33 +++ .../Runtime/Internal/IReducer.cs | 2 +- .../Runtime/Internal/ITable.cs | 2 +- .../Runtime/Internal/Module.cs | 196 ++++-------------- crates/cli/Cargo.toml | 1 + crates/cli/examples/regen-csharp-moduledef.rs | 71 +++++++ crates/cli/src/subcommands/generate/csharp.rs | 115 +++++++--- .../snapshots/codegen__codegen_csharp.snap | 136 +++++++++++- crates/commitlog/LICENSE | 0 crates/durability/LICENSE | 0 crates/lib/src/db/auth.rs | 4 +- crates/lib/src/db/raw_def/v8.rs | 21 +- crates/lib/src/db/raw_def/v9.rs | 44 ++-- crates/lib/src/lib.rs | 18 +- crates/sats/src/algebraic_type.rs | 8 +- crates/sats/src/algebraic_type_ref.rs | 2 + crates/sats/src/array_type.rs | 3 +- crates/sats/src/map_type.rs | 4 +- crates/sats/src/primitives.rs | 5 +- crates/sats/src/product_type.rs | 6 +- crates/sats/src/product_type_element.rs | 5 +- crates/sats/src/ser/impls.rs | 5 +- crates/sats/src/sum_type.rs | 6 +- crates/sats/src/sum_type_variant.rs | 4 +- crates/sats/src/typespace.rs | 31 +-- .../cursive-chat/module_bindings/message.rs | 0 .../cursive-chat/module_bindings/mod.rs | 0 .../module_bindings/send_message_reducer.rs | 0 .../module_bindings/set_name_reducer.rs | 0 .../cursive-chat/module_bindings/user.rs | 0 65 files changed, 1602 insertions(+), 507 deletions(-) create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/IndexType.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/Lifecycle.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/MiscModuleExport.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawColumnDefV8.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawConstraintDefV8.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexAlgorithm.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV8.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawMiscModuleExportV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDef.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV8.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawReducerDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawScheduleDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawScopedTypeNameV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV8.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV8.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawTypeDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDefV9.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/ReducerDef.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/TableAccess.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/TableDesc.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/TableType.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/TypeAlias.cs create mode 100644 crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs create mode 100644 crates/cli/examples/regen-csharp-moduledef.rs mode change 120000 => 100644 crates/commitlog/LICENSE mode change 120000 => 100644 crates/durability/LICENSE mode change 120000 => 100644 crates/sdk/examples/cursive-chat/module_bindings/message.rs mode change 120000 => 100644 crates/sdk/examples/cursive-chat/module_bindings/mod.rs mode change 120000 => 100644 crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs mode change 120000 => 100644 crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs mode change 120000 => 100644 crates/sdk/examples/cursive-chat/module_bindings/user.rs diff --git a/.gitattributes b/.gitattributes index 3f2ae7121a3..b580e30701f 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1,3 @@ **/module_bindings/** linguist-generated=true eol=lf *.verified.cs linguist-generated=true eol=lf +/crates/bindings-csharp/Runtime/Internal/Autogen/*.cs linguist-generated=true diff --git a/Cargo.lock b/Cargo.lock index 2139342895a..e01e2d560ca 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4178,6 +4178,7 @@ dependencies = [ "duct", "email_address", "flate2", + "fs-err", "futures", "http", "indicatif", diff --git a/crates/bindings-csharp/BSATN.Codegen/Type.cs b/crates/bindings-csharp/BSATN.Codegen/Type.cs index 917d1121fbc..6c0bc947b41 100644 --- a/crates/bindings-csharp/BSATN.Codegen/Type.cs +++ b/crates/bindings-csharp/BSATN.Codegen/Type.cs @@ -27,14 +27,10 @@ IEnumerable members } public static string GenerateDefs(IEnumerable members) => - $$""" - new SpacetimeDB.BSATN.AggregateElement[] { - {{string.Join( - ",\n", - members.Select(m => $"new(nameof({m.Name}), {m.Name}.GetAlgebraicType(registrar))") - )}} - } - """; + string.Join( + ",\n", + members.Select(m => $"new(nameof({m.Name}), {m.Name}.GetAlgebraicType(registrar))") + ); } public enum TypeKind @@ -230,9 +226,9 @@ public void Write(System.IO.BinaryWriter writer, {{ShortName}} value) { } public SpacetimeDB.BSATN.AlgebraicType GetAlgebraicType(SpacetimeDB.BSATN.ITypeRegistrar registrar) => - registrar.RegisterType<{{ShortName}}>(_ => new SpacetimeDB.BSATN.AlgebraicType.{{Kind}}( + registrar.RegisterType<{{ShortName}}>(_ => new SpacetimeDB.BSATN.AlgebraicType.{{Kind}}(new SpacetimeDB.BSATN.AggregateElement[] { {{MemberDeclaration.GenerateDefs(Members)}} - )); + })); } """ ); diff --git a/crates/bindings-csharp/Codegen.Tests/TestInit.cs b/crates/bindings-csharp/Codegen.Tests/TestInit.cs index 803b2db310f..22ea757ff62 100644 --- a/crates/bindings-csharp/Codegen.Tests/TestInit.cs +++ b/crates/bindings-csharp/Codegen.Tests/TestInit.cs @@ -23,16 +23,17 @@ public static void Initialize() unformattedCode, new() { IncludeGenerated = true, EndOfLine = CSharpier.EndOfLine.LF } ); + sb.Append(result.Code); + // Print errors in the end so that their line numbers are still meaningful. if (result.CompilationErrors.Any()) { + sb.AppendLine(); sb.AppendLine("// Generated code produced compilation errors:"); foreach (var diag in result.CompilationErrors) { sb.Append("// ").AppendLine(diag.ToString()); } - sb.AppendLine(); } - sb.Append(result.Code); }, ScrubberLocation.Last ); diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs index 74778a26efa..09aa21adab6 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#FFI.verified.cs @@ -10,12 +10,9 @@ static class ModuleRegistration { class Init : SpacetimeDB.Internal.IReducer { - public SpacetimeDB.Internal.Module.ReducerDef MakeReducerDef( + public SpacetimeDB.Internal.ReducerDef MakeReducerDef( SpacetimeDB.BSATN.ITypeRegistrar registrar - ) - { - return new("__init__", new SpacetimeDB.BSATN.AggregateElement[] { }); - } + ) => new("__init__", []); public void Invoke(BinaryReader reader, SpacetimeDB.ReducerContext ctx) { @@ -27,18 +24,9 @@ class InsertData : SpacetimeDB.Internal.IReducer { private static readonly PublicTable.BSATN data = new(); - public SpacetimeDB.Internal.Module.ReducerDef MakeReducerDef( + public SpacetimeDB.Internal.ReducerDef MakeReducerDef( SpacetimeDB.BSATN.ITypeRegistrar registrar - ) - { - return new( - "InsertData", - new SpacetimeDB.BSATN.AggregateElement[] - { - new(nameof(data), data.GetAlgebraicType(registrar)) - } - ); - } + ) => new("InsertData", [new(nameof(data), data.GetAlgebraicType(registrar))]); public void Invoke(BinaryReader reader, SpacetimeDB.ReducerContext ctx) { @@ -50,18 +38,13 @@ class InsertData2 : SpacetimeDB.Internal.IReducer { private static readonly PublicTable.BSATN data = new(); - public SpacetimeDB.Internal.Module.ReducerDef MakeReducerDef( + public SpacetimeDB.Internal.ReducerDef MakeReducerDef( SpacetimeDB.BSATN.ITypeRegistrar registrar - ) - { - return new( + ) => + new( "test_custom_name_and_reducer_ctx", - new SpacetimeDB.BSATN.AggregateElement[] - { - new(nameof(data), data.GetAlgebraicType(registrar)) - } + [new(nameof(data), data.GetAlgebraicType(registrar))] ); - } public void Invoke(BinaryReader reader, SpacetimeDB.ReducerContext ctx) { @@ -73,18 +56,9 @@ class ScheduleImmediate : SpacetimeDB.Internal.IReducer { private static readonly PublicTable.BSATN data = new(); - public SpacetimeDB.Internal.Module.ReducerDef MakeReducerDef( + public SpacetimeDB.Internal.ReducerDef MakeReducerDef( SpacetimeDB.BSATN.ITypeRegistrar registrar - ) - { - return new( - "ScheduleImmediate", - new SpacetimeDB.BSATN.AggregateElement[] - { - new(nameof(data), data.GetAlgebraicType(registrar)) - } - ); - } + ) => new("ScheduleImmediate", [new(nameof(data), data.GetAlgebraicType(registrar))]); public void Invoke(BinaryReader reader, SpacetimeDB.ReducerContext ctx) { @@ -96,18 +70,9 @@ class SendScheduledMessage : SpacetimeDB.Internal.IReducer { private static readonly Timers.SendMessageTimer.BSATN arg = new(); - public SpacetimeDB.Internal.Module.ReducerDef MakeReducerDef( + public SpacetimeDB.Internal.ReducerDef MakeReducerDef( SpacetimeDB.BSATN.ITypeRegistrar registrar - ) - { - return new( - "SendScheduledMessage", - new SpacetimeDB.BSATN.AggregateElement[] - { - new(nameof(arg), arg.GetAlgebraicType(registrar)) - } - ); - } + ) => new("SendScheduledMessage", [new(nameof(arg), arg.GetAlgebraicType(registrar))]); public void Invoke(BinaryReader reader, SpacetimeDB.ReducerContext ctx) { diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PrivateTable.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PrivateTable.verified.cs index bc9d9390308..a25e8acba60 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PrivateTable.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PrivateTable.verified.cs @@ -28,17 +28,24 @@ SpacetimeDB.BSATN.ITypeRegistrar registrar public void ReadGenFields(System.IO.BinaryReader reader) { } - static SpacetimeDB.Internal.Module.TableDesc SpacetimeDB.Internal.ITable.MakeTableDesc( + static SpacetimeDB.Internal.TableDesc SpacetimeDB.Internal.ITable.MakeTableDesc( SpacetimeDB.BSATN.ITypeRegistrar registrar ) => new( new( - nameof(PrivateTable), - new SpacetimeDB.Internal.Module.ColumnDefWithAttrs[] { }, - false, - null + TableName: nameof(PrivateTable), + Columns: [], + Indexes: [], + Constraints: [], + Sequences: [], + // "system" | "user" + TableType: "user", + // "public" | "private" + TableAccess: "private", + Scheduled: null ), - (SpacetimeDB.BSATN.AlgebraicType.Ref)new BSATN().GetAlgebraicType(registrar) + (uint) + ((SpacetimeDB.BSATN.AlgebraicType.Ref)new BSATN().GetAlgebraicType(registrar)).Ref_ ); static SpacetimeDB.Internal.Filter SpacetimeDB.Internal.ITable.CreateFilter() => diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PublicTable.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PublicTable.verified.cs index 16ca21966ba..d85fda78e6b 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PublicTable.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#PublicTable.verified.cs @@ -196,163 +196,77 @@ public void ReadGenFields(System.IO.BinaryReader reader) } } - static SpacetimeDB.Internal.Module.TableDesc SpacetimeDB.Internal.ITable.MakeTableDesc( + static SpacetimeDB.Internal.TableDesc SpacetimeDB.Internal.ITable.MakeTableDesc( SpacetimeDB.BSATN.ITypeRegistrar registrar ) => new( new( - nameof(PublicTable), - new SpacetimeDB.Internal.Module.ColumnDefWithAttrs[] - { - new( - new(nameof(Id), BSATN.Id.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.PrimaryKeyAuto - ), - new( - new(nameof(ByteField), BSATN.ByteField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(UshortField), BSATN.UshortField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(UintField), BSATN.UintField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(UlongField), BSATN.UlongField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(UInt128Field), BSATN.UInt128Field.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(U128Field), BSATN.U128Field.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(U256Field), BSATN.U256Field.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(SbyteField), BSATN.SbyteField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(ShortField), BSATN.ShortField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(IntField), BSATN.IntField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(LongField), BSATN.LongField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(Int128Field), BSATN.Int128Field.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet + TableName: nameof(PublicTable), + Columns: + [ + new(nameof(Id), BSATN.Id.GetAlgebraicType(registrar)), + new(nameof(ByteField), BSATN.ByteField.GetAlgebraicType(registrar)), + new(nameof(UshortField), BSATN.UshortField.GetAlgebraicType(registrar)), + new(nameof(UintField), BSATN.UintField.GetAlgebraicType(registrar)), + new(nameof(UlongField), BSATN.UlongField.GetAlgebraicType(registrar)), + new(nameof(UInt128Field), BSATN.UInt128Field.GetAlgebraicType(registrar)), + new(nameof(U128Field), BSATN.U128Field.GetAlgebraicType(registrar)), + new(nameof(U256Field), BSATN.U256Field.GetAlgebraicType(registrar)), + new(nameof(SbyteField), BSATN.SbyteField.GetAlgebraicType(registrar)), + new(nameof(ShortField), BSATN.ShortField.GetAlgebraicType(registrar)), + new(nameof(IntField), BSATN.IntField.GetAlgebraicType(registrar)), + new(nameof(LongField), BSATN.LongField.GetAlgebraicType(registrar)), + new(nameof(Int128Field), BSATN.Int128Field.GetAlgebraicType(registrar)), + new(nameof(I128Field), BSATN.I128Field.GetAlgebraicType(registrar)), + new(nameof(I256Field), BSATN.I256Field.GetAlgebraicType(registrar)), + new(nameof(BoolField), BSATN.BoolField.GetAlgebraicType(registrar)), + new(nameof(FloatField), BSATN.FloatField.GetAlgebraicType(registrar)), + new(nameof(DoubleField), BSATN.DoubleField.GetAlgebraicType(registrar)), + new(nameof(StringField), BSATN.StringField.GetAlgebraicType(registrar)), + new(nameof(IdentityField), BSATN.IdentityField.GetAlgebraicType(registrar)), + new(nameof(AddressField), BSATN.AddressField.GetAlgebraicType(registrar)), + new( + nameof(CustomStructField), + BSATN.CustomStructField.GetAlgebraicType(registrar) ), new( - new(nameof(I128Field), BSATN.I128Field.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet + nameof(CustomClassField), + BSATN.CustomClassField.GetAlgebraicType(registrar) ), + new(nameof(CustomEnumField), BSATN.CustomEnumField.GetAlgebraicType(registrar)), new( - new(nameof(I256Field), BSATN.I256Field.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(BoolField), BSATN.BoolField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(FloatField), BSATN.FloatField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(DoubleField), BSATN.DoubleField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(StringField), BSATN.StringField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(IdentityField), BSATN.IdentityField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(AddressField), BSATN.AddressField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new( - nameof(CustomStructField), - BSATN.CustomStructField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new( - nameof(CustomClassField), - BSATN.CustomClassField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new( - nameof(CustomEnumField), - BSATN.CustomEnumField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new( - nameof(CustomTaggedEnumField), - BSATN.CustomTaggedEnumField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(ListField), BSATN.ListField.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new( - nameof(DictionaryField), - BSATN.DictionaryField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet + nameof(CustomTaggedEnumField), + BSATN.CustomTaggedEnumField.GetAlgebraicType(registrar) ), + new(nameof(ListField), BSATN.ListField.GetAlgebraicType(registrar)), + new(nameof(DictionaryField), BSATN.DictionaryField.GetAlgebraicType(registrar)), new( - new( - nameof(NullableValueField), - BSATN.NullableValueField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet + nameof(NullableValueField), + BSATN.NullableValueField.GetAlgebraicType(registrar) ), new( - new( - nameof(NullableReferenceField), - BSATN.NullableReferenceField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet + nameof(NullableReferenceField), + BSATN.NullableReferenceField.GetAlgebraicType(registrar) ), new( - new( - nameof(ComplexNestedField), - BSATN.ComplexNestedField.GetAlgebraicType(registrar) - ), - SpacetimeDB.ColumnAttrs.UnSet + nameof(ComplexNestedField), + BSATN.ComplexNestedField.GetAlgebraicType(registrar) ) - }, - false, - null + ], + Indexes: [], + Constraints: + [ + new(nameof(PublicTable), 0, nameof(Id), SpacetimeDB.ColumnAttrs.PrimaryKeyAuto) + ], + Sequences: [], + // "system" | "user" + TableType: "user", + // "public" | "private" + TableAccess: "private", + Scheduled: null ), - (SpacetimeDB.BSATN.AlgebraicType.Ref)new BSATN().GetAlgebraicType(registrar) + (uint) + ((SpacetimeDB.BSATN.AlgebraicType.Ref)new BSATN().GetAlgebraicType(registrar)).Ref_ ); static SpacetimeDB.Internal.Filter SpacetimeDB.Internal.ITable.CreateFilter() => diff --git a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#Timers.SendMessageTimer.verified.cs b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#Timers.SendMessageTimer.verified.cs index ab50a97a8a5..f864317e21d 100644 --- a/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#Timers.SendMessageTimer.verified.cs +++ b/crates/bindings-csharp/Codegen.Tests/fixtures/server/snapshots/Module#Timers.SendMessageTimer.verified.cs @@ -61,31 +61,39 @@ public void ReadGenFields(System.IO.BinaryReader reader) } } - static SpacetimeDB.Internal.Module.TableDesc SpacetimeDB.Internal.ITable.MakeTableDesc( + static SpacetimeDB.Internal.TableDesc SpacetimeDB.Internal.ITable.MakeTableDesc( SpacetimeDB.BSATN.ITypeRegistrar registrar ) => new( new( - nameof(SendMessageTimer), - new SpacetimeDB.Internal.Module.ColumnDefWithAttrs[] - { + TableName: nameof(SendMessageTimer), + Columns: + [ + new(nameof(Text), BSATN.Text.GetAlgebraicType(registrar)), + new(nameof(ScheduledId), BSATN.ScheduledId.GetAlgebraicType(registrar)), + new(nameof(ScheduledAt), BSATN.ScheduledAt.GetAlgebraicType(registrar)) + ], + Indexes: [], + Constraints: + [ new( - new(nameof(Text), BSATN.Text.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet - ), - new( - new(nameof(ScheduledId), BSATN.ScheduledId.GetAlgebraicType(registrar)), + nameof(SendMessageTimer), + 1, + nameof(ScheduledId), SpacetimeDB.ColumnAttrs.PrimaryKeyAuto - ), - new( - new(nameof(ScheduledAt), BSATN.ScheduledAt.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.UnSet ) - }, - false, - "SendScheduledMessage" + ], + Sequences: [], + // "system" | "user" + TableType: "user", + // "public" | "private" + TableAccess: "private", + Scheduled: nameof(SendScheduledMessage) ), - (SpacetimeDB.BSATN.AlgebraicType.Ref)new BSATN().GetAlgebraicType(registrar) + (uint) + ( + (SpacetimeDB.BSATN.AlgebraicType.Ref)new BSATN().GetAlgebraicType(registrar) + ).Ref_ ); static SpacetimeDB.Internal.Filter SpacetimeDB.Internal.ITable.CreateFilter() => diff --git a/crates/bindings-csharp/Codegen/Module.cs b/crates/bindings-csharp/Codegen/Module.cs index 405edbbcd2e..6f81956eeff 100644 --- a/crates/bindings-csharp/Codegen/Module.cs +++ b/crates/bindings-csharp/Codegen/Module.cs @@ -96,13 +96,8 @@ or SpecialType.System_Int64 } // For the `TableDesc` constructor. - public string GenerateColumnDefWithAttrs() => - $""" - new ( - new (nameof({Name}), BSATN.{Name}.GetAlgebraicType(registrar)), - SpacetimeDB.ColumnAttrs.{Attrs} - ) - """; + public string GenerateColumnDef() => + $"new (nameof({Name}), BSATN.{Name}.GetAlgebraicType(registrar))"; // For the `Filter` constructor. public string GenerateFilterEntry() => @@ -202,16 +197,40 @@ public void ReadGenFields(System.IO.BinaryReader reader) { )}} } - static SpacetimeDB.Internal.Module.TableDesc {{iTable}}.MakeTableDesc(SpacetimeDB.BSATN.ITypeRegistrar registrar) => new ( + static SpacetimeDB.Internal.TableDesc {{iTable}}.MakeTableDesc(SpacetimeDB.BSATN.ITypeRegistrar registrar) => new ( new ( - nameof({{ShortName}}), - new SpacetimeDB.Internal.Module.ColumnDefWithAttrs[] { - {{string.Join(",\n", Members.Select(f => f.GenerateColumnDefWithAttrs()))}} - }, - {{IsPublic.ToString().ToLower()}}, - {{(Scheduled is not null ? $"\"{Scheduled}\"" : "null")}} + TableName: nameof({{ShortName}}), + Columns: [ + {{string.Join(",\n", Members.Select(m => m.GenerateColumnDef()))}} + ], + Indexes: [], + Constraints: [ + {{string.Join( + ",\n", + Members + // Important: the position must be stored here, before filtering. + .Select((col, pos) => (col, pos)) + .Where(pair => pair.col.Attrs != ColumnAttrs.UnSet) + .Select(pair => + $$""" + new ( + nameof({{ShortName}}), + {{pair.pos}}, + nameof({{pair.col.Name}}), + SpacetimeDB.ColumnAttrs.{{pair.col.Attrs}} + ) + """ + ) + )}} + ], + Sequences: [], + // "system" | "user" + TableType: "user", + // "public" | "private" + TableAccess: "{{(IsPublic ? "public" : "private")}}", + Scheduled: {{(Scheduled is not null ? $"nameof({Scheduled})" : "null")}} ), - (SpacetimeDB.BSATN.AlgebraicType.Ref) new BSATN().GetAlgebraicType(registrar) + (uint) ((SpacetimeDB.BSATN.AlgebraicType.Ref) new BSATN().GetAlgebraicType(registrar)).Ref_ ); static SpacetimeDB.Internal.Filter {{iTable}}.CreateFilter() => new([ @@ -311,12 +330,10 @@ public KeyValuePair GenerateClass() class {{Name}}: SpacetimeDB.Internal.IReducer { {{MemberDeclaration.GenerateBsatnFields(Accessibility.Private, NonContextArgs)}} - public SpacetimeDB.Internal.Module.ReducerDef MakeReducerDef(SpacetimeDB.BSATN.ITypeRegistrar registrar) { - return new ( - "{{ExportName}}", - {{MemberDeclaration.GenerateDefs(NonContextArgs)}} - ); - } + public SpacetimeDB.Internal.ReducerDef MakeReducerDef(SpacetimeDB.BSATN.ITypeRegistrar registrar) => new ( + "{{ExportName}}", + [{{MemberDeclaration.GenerateDefs(NonContextArgs)}}] + ); public void Invoke(BinaryReader reader, SpacetimeDB.ReducerContext ctx) { {{FullName}}( diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/IndexType.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/IndexType.cs new file mode 100644 index 00000000000..fef78137521 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/IndexType.cs @@ -0,0 +1,18 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public enum IndexType + { + BTree, + Hash, + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/Lifecycle.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/Lifecycle.cs new file mode 100644 index 00000000000..9da28d0e61a --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/Lifecycle.cs @@ -0,0 +1,19 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public enum Lifecycle + { + Init, + OnConnect, + OnDisconnect, + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/MiscModuleExport.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/MiscModuleExport.cs new file mode 100644 index 00000000000..c5bda8961ce --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/MiscModuleExport.cs @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public partial record MiscModuleExport : SpacetimeDB.TaggedEnum<( + SpacetimeDB.Internal.TypeAlias TypeAlias, + SpacetimeDB.Unit _Reserved + )>; +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawColumnDefV8.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawColumnDefV8.cs new file mode 100644 index 00000000000..72c6d2cf12e --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawColumnDefV8.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawColumnDefV8 + { + [DataMember(Name = "col_name")] + public string ColName; + [DataMember(Name = "col_type")] + public SpacetimeDB.BSATN.AlgebraicType ColType; + + public RawColumnDefV8( + string ColName, + SpacetimeDB.BSATN.AlgebraicType ColType + ) + { + this.ColName = ColName; + this.ColType = ColType; + } + + public RawColumnDefV8() : this( + "", + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawConstraintDefV8.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawConstraintDefV8.cs new file mode 100644 index 00000000000..a4d3d30a2fe --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawConstraintDefV8.cs @@ -0,0 +1,43 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawConstraintDefV8 + { + [DataMember(Name = "constraint_name")] + public string ConstraintName; + [DataMember(Name = "constraints")] + public byte Constraints; + [DataMember(Name = "columns")] + public System.Collections.Generic.List Columns; + + public RawConstraintDefV8( + string ConstraintName, + byte Constraints, + System.Collections.Generic.List Columns + ) + { + this.ConstraintName = ConstraintName; + this.Constraints = Constraints; + this.Columns = Columns; + } + + public RawConstraintDefV8() : this( + "", + default!, + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexAlgorithm.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexAlgorithm.cs new file mode 100644 index 00000000000..4d2bc783901 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexAlgorithm.cs @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public partial record RawIndexAlgorithm : SpacetimeDB.TaggedEnum<( + System.Collections.Generic.List BTree, + System.Collections.Generic.List Hash + )>; +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV8.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV8.cs new file mode 100644 index 00000000000..15b9825ea92 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV8.cs @@ -0,0 +1,48 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawIndexDefV8 + { + [DataMember(Name = "index_name")] + public string IndexName; + [DataMember(Name = "is_unique")] + public bool IsUnique; + [DataMember(Name = "index_type")] + public SpacetimeDB.Internal.IndexType IndexType; + [DataMember(Name = "columns")] + public System.Collections.Generic.List Columns; + + public RawIndexDefV8( + string IndexName, + bool IsUnique, + SpacetimeDB.Internal.IndexType IndexType, + System.Collections.Generic.List Columns + ) + { + this.IndexName = IndexName; + this.IsUnique = IsUnique; + this.IndexType = IndexType; + this.Columns = Columns; + } + + public RawIndexDefV8() : this( + "", + default!, + default!, + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV9.cs new file mode 100644 index 00000000000..ca8c9b3ff25 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawIndexDefV9.cs @@ -0,0 +1,43 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawIndexDefV9 + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "accessor_name")] + public string? AccessorName; + [DataMember(Name = "algorithm")] + public SpacetimeDB.Internal.RawIndexAlgorithm Algorithm; + + public RawIndexDefV9( + string Name, + string? AccessorName, + SpacetimeDB.Internal.RawIndexAlgorithm Algorithm + ) + { + this.Name = Name; + this.AccessorName = AccessorName; + this.Algorithm = Algorithm; + } + + public RawIndexDefV9() : this( + "", + default!, + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawMiscModuleExportV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawMiscModuleExportV9.cs new file mode 100644 index 00000000000..59e6003ecfb --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawMiscModuleExportV9.cs @@ -0,0 +1,16 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public enum RawMiscModuleExportV9 + { + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDef.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDef.cs new file mode 100644 index 00000000000..90ed2e35a57 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDef.cs @@ -0,0 +1,17 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public partial record RawModuleDef : SpacetimeDB.TaggedEnum<( + SpacetimeDB.Internal.RawModuleDefV8 V8BackCompat, + SpacetimeDB.Internal.RawModuleDefV9 V9 + )>; +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV8.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV8.cs new file mode 100644 index 00000000000..45fbc5a1411 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV8.cs @@ -0,0 +1,48 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawModuleDefV8 + { + [DataMember(Name = "typespace")] + public SpacetimeDB.Internal.Typespace Typespace; + [DataMember(Name = "tables")] + public System.Collections.Generic.List Tables; + [DataMember(Name = "reducers")] + public System.Collections.Generic.List Reducers; + [DataMember(Name = "misc_exports")] + public System.Collections.Generic.List MiscExports; + + public RawModuleDefV8( + SpacetimeDB.Internal.Typespace Typespace, + System.Collections.Generic.List Tables, + System.Collections.Generic.List Reducers, + System.Collections.Generic.List MiscExports + ) + { + this.Typespace = Typespace; + this.Tables = Tables; + this.Reducers = Reducers; + this.MiscExports = MiscExports; + } + + public RawModuleDefV8() : this( + new(), + new(), + new(), + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV9.cs new file mode 100644 index 00000000000..a5d4b719957 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawModuleDefV9.cs @@ -0,0 +1,53 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawModuleDefV9 + { + [DataMember(Name = "typespace")] + public SpacetimeDB.Internal.Typespace Typespace; + [DataMember(Name = "tables")] + public System.Collections.Generic.List Tables; + [DataMember(Name = "reducers")] + public System.Collections.Generic.List Reducers; + [DataMember(Name = "types")] + public System.Collections.Generic.List Types; + [DataMember(Name = "misc_exports")] + public System.Collections.Generic.List MiscExports; + + public RawModuleDefV9( + SpacetimeDB.Internal.Typespace Typespace, + System.Collections.Generic.List Tables, + System.Collections.Generic.List Reducers, + System.Collections.Generic.List Types, + System.Collections.Generic.List MiscExports + ) + { + this.Typespace = Typespace; + this.Tables = Tables; + this.Reducers = Reducers; + this.Types = Types; + this.MiscExports = MiscExports; + } + + public RawModuleDefV9() : this( + new(), + new(), + new(), + new(), + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawReducerDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawReducerDefV9.cs new file mode 100644 index 00000000000..a4bed122926 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawReducerDefV9.cs @@ -0,0 +1,43 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawReducerDefV9 + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "params")] + public List Params; + [DataMember(Name = "lifecycle")] + public SpacetimeDB.Internal.Lifecycle? Lifecycle; + + public RawReducerDefV9( + string Name, + List Params, + SpacetimeDB.Internal.Lifecycle? Lifecycle + ) + { + this.Name = Name; + this.Params = Params; + this.Lifecycle = Lifecycle; + } + + public RawReducerDefV9() : this( + "", + new(), + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawScheduleDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawScheduleDefV9.cs new file mode 100644 index 00000000000..7527c7a53ed --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawScheduleDefV9.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawScheduleDefV9 + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "reducer_name")] + public string ReducerName; + + public RawScheduleDefV9( + string Name, + string ReducerName + ) + { + this.Name = Name; + this.ReducerName = ReducerName; + } + + public RawScheduleDefV9() : this( + "", + "" + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawScopedTypeNameV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawScopedTypeNameV9.cs new file mode 100644 index 00000000000..a1e7593683b --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawScopedTypeNameV9.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawScopedTypeNameV9 + { + [DataMember(Name = "scope")] + public System.Collections.Generic.List Scope; + [DataMember(Name = "name")] + public string Name; + + public RawScopedTypeNameV9( + System.Collections.Generic.List Scope, + string Name + ) + { + this.Scope = Scope; + this.Name = Name; + } + + public RawScopedTypeNameV9() : this( + new(), + "" + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV8.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV8.cs new file mode 100644 index 00000000000..830dbf586e1 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV8.cs @@ -0,0 +1,63 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawSequenceDefV8 + { + [DataMember(Name = "sequence_name")] + public string SequenceName; + [DataMember(Name = "col_pos")] + public ushort ColPos; + [DataMember(Name = "increment")] + public I128 Increment; + [DataMember(Name = "start")] + public I128? Start; + [DataMember(Name = "min_value")] + public I128? MinValue; + [DataMember(Name = "max_value")] + public I128? MaxValue; + [DataMember(Name = "allocated")] + public I128 Allocated; + + public RawSequenceDefV8( + string SequenceName, + ushort ColPos, + I128 Increment, + I128? Start, + I128? MinValue, + I128? MaxValue, + I128 Allocated + ) + { + this.SequenceName = SequenceName; + this.ColPos = ColPos; + this.Increment = Increment; + this.Start = Start; + this.MinValue = MinValue; + this.MaxValue = MaxValue; + this.Allocated = Allocated; + } + + public RawSequenceDefV8() : this( + "", + default!, + default!, + default!, + default!, + default!, + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV9.cs new file mode 100644 index 00000000000..dd631ebc056 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawSequenceDefV9.cs @@ -0,0 +1,58 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawSequenceDefV9 + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "column")] + public ushort Column; + [DataMember(Name = "start")] + public I128? Start; + [DataMember(Name = "min_value")] + public I128? MinValue; + [DataMember(Name = "max_value")] + public I128? MaxValue; + [DataMember(Name = "increment")] + public I128 Increment; + + public RawSequenceDefV9( + string Name, + ushort Column, + I128? Start, + I128? MinValue, + I128? MaxValue, + I128 Increment + ) + { + this.Name = Name; + this.Column = Column; + this.Start = Start; + this.MinValue = MinValue; + this.MaxValue = MaxValue; + this.Increment = Increment; + } + + public RawSequenceDefV9() : this( + "", + default!, + default!, + default!, + default!, + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV8.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV8.cs new file mode 100644 index 00000000000..ee0650dab0c --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV8.cs @@ -0,0 +1,68 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawTableDefV8 + { + [DataMember(Name = "table_name")] + public string TableName; + [DataMember(Name = "columns")] + public System.Collections.Generic.List Columns; + [DataMember(Name = "indexes")] + public System.Collections.Generic.List Indexes; + [DataMember(Name = "constraints")] + public System.Collections.Generic.List Constraints; + [DataMember(Name = "sequences")] + public System.Collections.Generic.List Sequences; + [DataMember(Name = "table_type")] + public string TableType; + [DataMember(Name = "table_access")] + public string TableAccess; + [DataMember(Name = "scheduled")] + public string? Scheduled; + + public RawTableDefV8( + string TableName, + System.Collections.Generic.List Columns, + System.Collections.Generic.List Indexes, + System.Collections.Generic.List Constraints, + System.Collections.Generic.List Sequences, + string TableType, + string TableAccess, + string? Scheduled + ) + { + this.TableName = TableName; + this.Columns = Columns; + this.Indexes = Indexes; + this.Constraints = Constraints; + this.Sequences = Sequences; + this.TableType = TableType; + this.TableAccess = TableAccess; + this.Scheduled = Scheduled; + } + + public RawTableDefV8() : this( + "", + new(), + new(), + new(), + new(), + "", + "", + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV9.cs new file mode 100644 index 00000000000..09c9c6cdd01 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawTableDefV9.cs @@ -0,0 +1,73 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawTableDefV9 + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "product_type_ref")] + public uint ProductTypeRef; + [DataMember(Name = "primary_key")] + public ushort? PrimaryKey; + [DataMember(Name = "indexes")] + public System.Collections.Generic.List Indexes; + [DataMember(Name = "unique_constraints")] + public System.Collections.Generic.List UniqueConstraints; + [DataMember(Name = "sequences")] + public System.Collections.Generic.List Sequences; + [DataMember(Name = "schedule")] + public SpacetimeDB.Internal.RawScheduleDefV9? Schedule; + [DataMember(Name = "table_type")] + public SpacetimeDB.Internal.TableType TableType; + [DataMember(Name = "table_access")] + public SpacetimeDB.Internal.TableAccess TableAccess; + + public RawTableDefV9( + string Name, + uint ProductTypeRef, + ushort? PrimaryKey, + System.Collections.Generic.List Indexes, + System.Collections.Generic.List UniqueConstraints, + System.Collections.Generic.List Sequences, + SpacetimeDB.Internal.RawScheduleDefV9? Schedule, + SpacetimeDB.Internal.TableType TableType, + SpacetimeDB.Internal.TableAccess TableAccess + ) + { + this.Name = Name; + this.ProductTypeRef = ProductTypeRef; + this.PrimaryKey = PrimaryKey; + this.Indexes = Indexes; + this.UniqueConstraints = UniqueConstraints; + this.Sequences = Sequences; + this.Schedule = Schedule; + this.TableType = TableType; + this.TableAccess = TableAccess; + } + + public RawTableDefV9() : this( + "", + default!, + default!, + new(), + new(), + new(), + default!, + default!, + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawTypeDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawTypeDefV9.cs new file mode 100644 index 00000000000..4d2af6c33fe --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawTypeDefV9.cs @@ -0,0 +1,43 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawTypeDefV9 + { + [DataMember(Name = "name")] + public SpacetimeDB.Internal.RawScopedTypeNameV9 Name; + [DataMember(Name = "ty")] + public uint Ty; + [DataMember(Name = "custom_ordering")] + public bool CustomOrdering; + + public RawTypeDefV9( + SpacetimeDB.Internal.RawScopedTypeNameV9 Name, + uint Ty, + bool CustomOrdering + ) + { + this.Name = Name; + this.Ty = Ty; + this.CustomOrdering = CustomOrdering; + } + + public RawTypeDefV9() : this( + new(), + default!, + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDefV9.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDefV9.cs new file mode 100644 index 00000000000..a264a26a563 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/RawUniqueConstraintDefV9.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class RawUniqueConstraintDefV9 + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "columns")] + public System.Collections.Generic.List Columns; + + public RawUniqueConstraintDefV9( + string Name, + System.Collections.Generic.List Columns + ) + { + this.Name = Name; + this.Columns = Columns; + } + + public RawUniqueConstraintDefV9() : this( + "", + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/ReducerDef.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/ReducerDef.cs new file mode 100644 index 00000000000..50c5b84f350 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/ReducerDef.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class ReducerDef + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "args")] + public System.Collections.Generic.List Args; + + public ReducerDef( + string Name, + System.Collections.Generic.List Args + ) + { + this.Name = Name; + this.Args = Args; + } + + public ReducerDef() : this( + "", + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/TableAccess.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/TableAccess.cs new file mode 100644 index 00000000000..eb8399d30a0 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/TableAccess.cs @@ -0,0 +1,18 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public enum TableAccess + { + Public, + Private, + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/TableDesc.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/TableDesc.cs new file mode 100644 index 00000000000..3cd6d77c3f4 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/TableDesc.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class TableDesc + { + [DataMember(Name = "schema")] + public SpacetimeDB.Internal.RawTableDefV8 Schema; + [DataMember(Name = "data")] + public uint Data; + + public TableDesc( + SpacetimeDB.Internal.RawTableDefV8 Schema, + uint Data + ) + { + this.Schema = Schema; + this.Data = Data; + } + + public TableDesc() : this( + new(), + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/TableType.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/TableType.cs new file mode 100644 index 00000000000..5c20135bed7 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/TableType.cs @@ -0,0 +1,18 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + public enum TableType + { + System, + User, + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/TypeAlias.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/TypeAlias.cs new file mode 100644 index 00000000000..c2eb1d665cc --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/TypeAlias.cs @@ -0,0 +1,38 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class TypeAlias + { + [DataMember(Name = "name")] + public string Name; + [DataMember(Name = "ty")] + public uint Ty; + + public TypeAlias( + string Name, + uint Ty + ) + { + this.Name = Name; + this.Ty = Ty; + } + + public TypeAlias() : this( + "", + default! + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs b/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs new file mode 100644 index 00000000000..3bd98ea8577 --- /dev/null +++ b/crates/bindings-csharp/Runtime/Internal/Autogen/Typespace.cs @@ -0,0 +1,33 @@ +// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE +// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD. +// + +#nullable enable + +using System; +using SpacetimeDB; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.Serialization; + +namespace SpacetimeDB.Internal +{ + [SpacetimeDB.Type] + [DataContract] + public partial class Typespace + { + [DataMember(Name = "types")] + public System.Collections.Generic.List Types; + + public Typespace( + System.Collections.Generic.List Types + ) + { + this.Types = Types; + } + + public Typespace() : this( + new() + ) { } + } +} diff --git a/crates/bindings-csharp/Runtime/Internal/IReducer.cs b/crates/bindings-csharp/Runtime/Internal/IReducer.cs index b5082cfeb1b..bb5c8e1fa95 100644 --- a/crates/bindings-csharp/Runtime/Internal/IReducer.cs +++ b/crates/bindings-csharp/Runtime/Internal/IReducer.cs @@ -5,7 +5,7 @@ namespace SpacetimeDB.Internal; public interface IReducer { - Module.ReducerDef MakeReducerDef(ITypeRegistrar registrar); + ReducerDef MakeReducerDef(ITypeRegistrar registrar); // This one is not static because we need to be able to store IReducer in a list. void Invoke(BinaryReader reader, ReducerContext args); diff --git a/crates/bindings-csharp/Runtime/Internal/ITable.cs b/crates/bindings-csharp/Runtime/Internal/ITable.cs index 951a5beeba1..2233e04db84 100644 --- a/crates/bindings-csharp/Runtime/Internal/ITable.cs +++ b/crates/bindings-csharp/Runtime/Internal/ITable.cs @@ -8,7 +8,7 @@ public interface ITable : IStructuralReadWrite { // These are the methods that codegen needs to implement. void ReadGenFields(BinaryReader reader); - static abstract Module.TableDesc MakeTableDesc(ITypeRegistrar registrar); + static abstract TableDesc MakeTableDesc(ITypeRegistrar registrar); static abstract Filter CreateFilter(); // These are static helpers that codegen can use. diff --git a/crates/bindings-csharp/Runtime/Internal/Module.cs b/crates/bindings-csharp/Runtime/Internal/Module.cs index 7e05dc51ee6..f2e2e4d9486 100644 --- a/crates/bindings-csharp/Runtime/Internal/Module.cs +++ b/crates/bindings-csharp/Runtime/Internal/Module.cs @@ -5,176 +5,60 @@ namespace SpacetimeDB.Internal; using SpacetimeDB; using SpacetimeDB.BSATN; -public static partial class Module +partial class RawConstraintDefV8 { - [SpacetimeDB.Type] - public enum IndexType : byte - { - BTree, - Hash, - } - - [SpacetimeDB.Type] - public partial struct IndexDef(string name, IndexType type, bool isUnique, ushort[] columnIds) - { - string IndexName = name; - bool IsUnique = isUnique; - IndexType Type = type; - ushort[] ColumnIds = columnIds; - } - - [SpacetimeDB.Type] - public partial struct ColumnDef(string name, AlgebraicType type) - { - internal string ColName = name; - AlgebraicType ColType = type; - } - - [SpacetimeDB.Type] - public partial struct ConstraintDef(string name, ColumnAttrs kind, ushort[] columnIds) - { - string ConstraintName = name; - - // bitflags should be serialized as bytes rather than sum types - byte Kind = (byte)kind; - ushort[] ColumnIds = columnIds; - } - - [SpacetimeDB.Type] - public partial struct SequenceDef( - string sequenceName, - ushort colPos, - Int128? increment = null, - Int128? start = null, - Int128? min_value = null, - Int128? max_value = null, - Int128? allocated = null - ) - { - string SequenceName = sequenceName; - ushort ColPos = colPos; - Int128 increment = increment ?? 1; - Int128? start = start; - Int128? min_value = min_value; - Int128? max_value = max_value; - Int128 allocated = allocated ?? 4_096; - } - - // Not part of the database schema, just used by the codegen to group column definitions with their attributes. - public struct ColumnDefWithAttrs(ColumnDef columnDef, ColumnAttrs attrs) - { - public ColumnDef ColumnDef = columnDef; - public ColumnAttrs Attrs = attrs; - } - - [SpacetimeDB.Type] - public partial struct TableDef( - string tableName, - ColumnDefWithAttrs[] columns, - bool isPublic, - string? scheduledReducer - ) - { - string TableName = tableName; - ColumnDef[] Columns = columns.Select(col => col.ColumnDef).ToArray(); - IndexDef[] Indices = []; - ConstraintDef[] Constraints = columns - // Important: the position must be stored here, before filtering. - .Select((col, pos) => (col, pos)) - .Where(pair => pair.col.Attrs != ColumnAttrs.UnSet) - .Select(pair => new ConstraintDef( - $"ct_{tableName}_{pair.col.ColumnDef.ColName}_{pair.col.Attrs}", - pair.col.Attrs, - [(ushort)pair.pos] - )) - .ToArray(); - SequenceDef[] Sequences = []; - - // "system" | "user" - string TableType = "user"; - - // "public" | "private" - string TableAccess = isPublic ? "public" : "private"; - - string? ScheduledReducer = scheduledReducer; - } + public RawConstraintDefV8(string tableName, ushort colIndex, string colName, ColumnAttrs attrs) + : this( + ConstraintName: $"ct_{tableName}_{colName}_{attrs}", + Constraints: (byte)attrs, + Columns: [colIndex] + ) { } +} - [SpacetimeDB.Type] - public partial struct TableDesc(TableDef schema, AlgebraicType.Ref typeRef) - { - TableDef Schema = schema; - int TypeRef = typeRef.Ref_; - } +partial class RawModuleDefV8 +{ + // Note: this intends to generate a valid identifier, but it's not guaranteed to be unique as it's not proper mangling. + // Fix it up to a different mangling scheme if it causes problems. + private static string GetFriendlyName(Type type) => + type.IsGenericType + ? $"{type.Name.Remove(type.Name.IndexOf('`'))}_{string.Join("_", type.GetGenericArguments().Select(GetFriendlyName))}" + : type.Name; - [SpacetimeDB.Type] - public partial struct ReducerDef(string name, AggregateElement[] args) + private void RegisterTypeName(AlgebraicType.Ref typeRef) { - string Name = name; - AggregateElement[] Args = args; + // If it's a table, it doesn't need an alias as name will be registered automatically. + if (typeof(T).IsDefined(typeof(TableAttribute), false)) + { + return; + } + MiscExports.Add( + new MiscModuleExport.TypeAlias(new(GetFriendlyName(typeof(T)), (uint)typeRef.Ref_)) + ); } - [SpacetimeDB.Type] - internal partial struct TypeAlias(string name, AlgebraicType.Ref typeRef) + internal AlgebraicType.Ref RegisterType(Func makeType) { - string Name = name; - int TypeRef = typeRef.Ref_; + var types = Typespace.Types; + var typeRef = new AlgebraicType.Ref(types.Count); + // Put a dummy self-reference just so that we get stable index even if `makeType` recursively adds more types. + types.Add(typeRef); + // Now we can safely call `makeType` and assign the result to the reserved slot. + types[typeRef.Ref_] = makeType(typeRef); + RegisterTypeName(typeRef); + return typeRef; } - [SpacetimeDB.Type] - internal partial record MiscModuleExport - : SpacetimeDB.TaggedEnum<(TypeAlias TypeAlias, Unit _Reserved)>; - - [SpacetimeDB.Type] - public partial struct RawModuleDefV8() - { - List Types = []; - List Tables = []; - List Reducers = []; - List MiscExports = []; - - // Note: this intends to generate a valid identifier, but it's not guaranteed to be unique as it's not proper mangling. - // Fix it up to a different mangling scheme if it causes problems. - private static string GetFriendlyName(Type type) => - type.IsGenericType - ? $"{type.Name.Remove(type.Name.IndexOf('`'))}_{string.Join("_", type.GetGenericArguments().Select(GetFriendlyName))}" - : type.Name; - - private void RegisterTypeName(AlgebraicType.Ref typeRef) - { - // If it's a table, it doesn't need an alias as name will be registered automatically. - if (typeof(T).IsDefined(typeof(TableAttribute), false)) - { - return; - } - MiscExports.Add( - new MiscModuleExport.TypeAlias(new(GetFriendlyName(typeof(T)), typeRef)) - ); - } - - internal AlgebraicType.Ref RegisterType(Func makeType) - { - var typeRef = new AlgebraicType.Ref(Types.Count); - // Put a dummy self-reference just so that we get stable index even if `makeType` recursively adds more types. - Types.Add(typeRef); - // Now we can safely call `makeType` and assign the result to the reserved slot. - Types[typeRef.Ref_] = makeType(typeRef); - RegisterTypeName(typeRef); - return typeRef; - } - - internal void RegisterReducer(ReducerDef reducer) => Reducers.Add(reducer); - - internal void RegisterTable(TableDesc table) => Tables.Add(table); - } + internal void RegisterReducer(ReducerDef reducer) => Reducers.Add(reducer); - [SpacetimeDB.Type] - internal partial record RawModuleDef - : SpacetimeDB.TaggedEnum<(RawModuleDefV8 V8BackCompat, Unit _Reserved)>; + internal void RegisterTable(TableDesc table) => Tables.Add(table); +} +public static class Module +{ private static readonly RawModuleDefV8 moduleDef = new(); private static readonly List reducers = []; - struct TypeRegistrar() : ITypeRegistrar + readonly struct TypeRegistrar() : ITypeRegistrar { private readonly Dictionary types = []; diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index b63a235a8be..9ed96517d4c 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -67,6 +67,7 @@ wasmtime.workspace = true [dev-dependencies] insta.workspace = true +fs-err.workspace = true spacetimedb-testing = { path = "../testing" } [features] diff --git a/crates/cli/examples/regen-csharp-moduledef.rs b/crates/cli/examples/regen-csharp-moduledef.rs new file mode 100644 index 00000000000..e52a055b51f --- /dev/null +++ b/crates/cli/examples/regen-csharp-moduledef.rs @@ -0,0 +1,71 @@ +//! This script is used to generate the C# bindings for the `RawModuleDef` type. +//! Run `cargo run --example regen-csharp-moduledef` to update C# bindings whenever the module definition changes. + +use fs_err as fs; +use regex::Regex; +use spacetimedb_cli::generate::{generate, Language}; +use spacetimedb_lib::{RawModuleDef, RawModuleDefV8}; +use std::path::Path; +use std::sync::OnceLock; + +macro_rules! regex_replace { + ($value:expr, $re:expr, $replace:expr) => {{ + static RE: OnceLock = OnceLock::new(); + RE.get_or_init(|| Regex::new($re).unwrap()) + .replace_all($value, $replace) + }}; +} + +fn main() -> anyhow::Result<()> { + let module = RawModuleDefV8::with_builder(|module| { + module.add_type::(); + }); + + let mut results = generate(module, Language::Csharp, "SpacetimeDB.Internal")?; + + // Someday we might replace custom BSATN types with autogenerated ones as well, + // but for now they're not very large and our copies are somewhat more optimised. + // + // Ignore those types and replace their references with our own with plain old regexes. + + results.retain(|(filename, _)| { + !(matches!(filename.as_str(), "AlgebraicType.cs" | "MapType.cs") + || filename.starts_with("_Globals") + || filename.starts_with("SumType") + || filename.starts_with("ProductType")) + }); + + for (_, code) in &mut results { + let res = regex_replace!( + code, + r"\b(SpacetimeDB\.)Internal(\.(Algebraic|Map)Type)\b", + "${1}BSATN${2}" + ); + let res = regex_replace!( + &res, + r"\b(SpacetimeDB\.)Internal\.(ProductTypeElement|SumTypeVariant)\b", + "${1}BSATN.AggregateElement" + ); + let res = regex_replace!( + &res, + r"\b(SpacetimeDB\.)Internal(\.(Product|Sum)Type)\b", + "List<${1}BSATN.AggregateElement>" + ); + *code = res.into_owned(); + } + + let dir = &Path::new(concat!( + env!("CARGO_MANIFEST_DIR"), + "/../bindings-csharp/Runtime/Internal/Autogen" + )) + .canonicalize()?; + + fs::remove_dir_all(dir)?; + fs::create_dir(dir)?; + + for (file, content) in results { + fs::write(dir.join(file), content)?; + } + + Ok(()) +} diff --git a/crates/cli/src/subcommands/generate/csharp.rs b/crates/cli/src/subcommands/generate/csharp.rs index c2ad715444b..f3cfffa69e3 100644 --- a/crates/cli/src/subcommands/generate/csharp.rs +++ b/crates/cli/src/subcommands/generate/csharp.rs @@ -96,25 +96,23 @@ fn ty_fmt<'a>(ctx: &'a GenCtx, ty: &'a AlgebraicType, namespace: &'a str) -> imp }) } -fn default_init(ctx: &GenCtx, ty: &AlgebraicType) -> &'static str { +fn default_init(ctx: &GenCtx, ty: &AlgebraicType) -> Option<&'static str> { match ty { - AlgebraicType::Sum(sum_type) => { - // Options have a default value of null which is fine for us, and simple enums have their own default. - if sum_type.as_option().is_some() || sum_type.is_simple_enum() { - "" - } else { - // TODO: generate some proper default here (what would it be for tagged enums?). - " = null!" - } - } + // Options have a default value of null which is fine for us, and simple enums have their own default. + AlgebraicType::Sum(sum_type) if sum_type.is_option() || sum_type.is_simple_enum() => None, + // TODO: generate some proper default here (what would it be for tagged enums?). + AlgebraicType::Sum(_) => Some("null!"), // Byte arrays must be initialized to an empty array. - ty if ty.is_bytes() => " = Array.Empty()", + ty if ty.is_bytes() => Some("Array.Empty()"), // For product types, arrays, and maps, we can use the default constructor. - AlgebraicType::Product(_) | AlgebraicType::Array(_) | AlgebraicType::Map(_) => " = new()", + AlgebraicType::Product(_) | AlgebraicType::Array(_) | AlgebraicType::Map(_) => Some("new()"), // Strings must have explicit default value of "". - AlgebraicType::String => r#" = """#, + AlgebraicType::String => Some(r#""""#), AlgebraicType::Ref(r) => default_init(ctx, &ctx.typespace[*r]), - _ => "", + _ => { + debug_assert!(ty.is_scalar()); + None + } } } @@ -248,6 +246,19 @@ pub fn autogen_csharp_sum(ctx: &GenCtx, name: &str, sum_type: &SumType, namespac .replace("r#", ""); write!(output, " {variant_name}"); } + // If we have less than 2 variants, we need to add some dummy variants to make the tuple work. + match sum_type.variants.len() { + 0 => { + writeln!(output); + writeln!(output, "SpacetimeDB.Unit _Reserved1,"); + write!(output, "SpacetimeDB.Unit _Reserved2"); + } + 1 => { + writeln!(output, ","); + write!(output, "SpacetimeDB.Unit _Reserved"); + } + _ => {} + } } writeln!(output); writeln!(output, ")>;"); @@ -315,23 +326,60 @@ fn autogen_csharp_product_table_common( } writeln!(output); indented_block(&mut output, |output| { - for field in &*product_type.elements { - let field_name = field - .name - .as_ref() - .expect("autogen'd tuples should have field names") - .replace("r#", ""); + let fields = product_type + .elements + .iter() + .map(|field| { + let orig_name = field + .name + .as_ref() + .expect("autogen'd tuples should have field names") + .replace("r#", ""); - writeln!(output, "[DataMember(Name = \"{field_name}\")]"); - writeln!( - output, - "public {} {}{};", - ty_fmt(ctx, &field.algebraic_type, namespace), - field_name.to_case(Case::Pascal), - default_init(ctx, &field.algebraic_type) - ); + writeln!(output, "[DataMember(Name = \"{orig_name}\")]"); + + let field_name = orig_name.to_case(Case::Pascal); + let ty = ty_fmt(ctx, &field.algebraic_type, namespace).to_string(); + + writeln!(output, "public {ty} {field_name};"); + + (field_name, ty) + }) + .collect::>(); + + // Generate fully-parameterized constructor. + writeln!(output); + writeln!(output, "public {name}("); + { + indent_scope!(output); + for (i, (field_name, ty)) in fields.iter().enumerate() { + if i != 0 { + writeln!(output, ","); + } + write!(output, "{ty} {field_name}"); + } } writeln!(output); + writeln!(output, ")"); + indented_block(output, |output| { + for (field_name, _ty) in fields.iter() { + writeln!(output, "this.{field_name} = {field_name};"); + } + }); + writeln!(output); + + // Generate default constructor (if the one above is not already parameterless). + if !fields.is_empty() { + writeln!(output, "public {name}()"); + indented_block(output, |output| { + for ((field_name, _ty), field) in fields.iter().zip(&*product_type.elements) { + if let Some(default) = default_init(ctx, &field.algebraic_type) { + writeln!(output, "this.{field_name} = {default};"); + } + } + }); + writeln!(output); + } // If this is a table, we want to generate event accessor and indexes if let Some(schema) = &schema { @@ -510,11 +558,12 @@ pub fn autogen_csharp_reducer(ctx: &GenCtx, reducer: &ReducerDef, namespace: &st func_params.push_str(", "); field_inits.push_str(", "); } - writeln!( - output, - "public {arg_type_str} {field_name}{};", - default_init(ctx, &arg.algebraic_type) - ); + write!(output, "public {arg_type_str} {field_name}"); + // Skip default initializer if it's the same as the implicit default. + if let Some(default) = default_init(ctx, &arg.algebraic_type) { + write!(output, " = {default}"); + } + writeln!(output, ";"); write!(func_params, "{arg_type_str} {arg_name}").unwrap(); write!(field_inits, "{field_name} = {arg_name}").unwrap(); } diff --git a/crates/cli/tests/snapshots/codegen__codegen_csharp.snap b/crates/cli/tests/snapshots/codegen__codegen_csharp.snap index a6101968518..57688366745 100644 --- a/crates/cli/tests/snapshots/codegen__codegen_csharp.snap +++ b/crates/cli/tests/snapshots/codegen__codegen_csharp.snap @@ -197,9 +197,24 @@ namespace SpacetimeDB public partial class HasSpecialStuff : SpacetimeDB.DatabaseTable { [DataMember(Name = "identity")] - public SpacetimeDB.Identity Identity = new(); + public SpacetimeDB.Identity Identity; [DataMember(Name = "address")] - public SpacetimeDB.Address Address = new(); + public SpacetimeDB.Address Address; + + public HasSpecialStuff( + SpacetimeDB.Identity Identity, + SpacetimeDB.Address Address + ) + { + this.Identity = Identity; + this.Address = Address; + } + + public HasSpecialStuff() + { + this.Identity = new(); + this.Address = new(); + } public static IEnumerable FilterByIdentity(SpacetimeDB.Identity value) { @@ -288,6 +303,19 @@ namespace SpacetimeDB [DataMember(Name = "other")] public uint Other; + public PkMultiIdentity( + uint Id, + uint Other + ) + { + this.Id = Id; + this.Other = Other; + } + + public PkMultiIdentity() + { + } + private static Dictionary Id_Index = new(16); private static Dictionary Other_Index = new(16); @@ -359,6 +387,19 @@ namespace SpacetimeDB [DataMember(Name = "y")] public long Y; + public Point( + long X, + long Y + ) + { + this.X = X; + this.Y = Y; + } + + public Point() + { + } + public static IEnumerable FilterByX(long value) { return Query(x => x.X == value); @@ -392,7 +433,19 @@ namespace SpacetimeDB public partial class Private : SpacetimeDB.DatabaseTable { [DataMember(Name = "name")] - public string Name = ""; + public string Name; + + public Private( + string Name + ) + { + this.Name = Name; + } + + public Private() + { + this.Name = ""; + } public static IEnumerable FilterByName(string value) { @@ -467,7 +520,23 @@ namespace SpacetimeDB [DataMember(Name = "scheduled_id")] public ulong ScheduledId; [DataMember(Name = "scheduled_at")] - public SpacetimeDB.ScheduleAt ScheduledAt = null!; + public SpacetimeDB.ScheduleAt ScheduledAt; + + public RepeatingTestArg( + ulong PrevTime, + ulong ScheduledId, + SpacetimeDB.ScheduleAt ScheduledAt + ) + { + this.PrevTime = PrevTime; + this.ScheduledId = ScheduledId; + this.ScheduledAt = ScheduledAt; + } + + public RepeatingTestArg() + { + this.ScheduledAt = null!; + } private static Dictionary ScheduledId_Index = new(16); @@ -572,7 +641,23 @@ namespace SpacetimeDB [DataMember(Name = "y")] public uint Y; [DataMember(Name = "z")] - public string Z = ""; + public string Z; + + public TestA( + uint X, + uint Y, + string Z + ) + { + this.X = X; + this.Y = Y; + this.Z = Z; + } + + public TestA() + { + this.Z = ""; + } public static IEnumerable FilterByX(uint value) { @@ -612,7 +697,19 @@ namespace SpacetimeDB public partial class TestB { [DataMember(Name = "foo")] - public string Foo = ""; + public string Foo; + + public TestB( + string Foo + ) + { + this.Foo = Foo; + } + + public TestB() + { + this.Foo = ""; + } } } @@ -638,6 +735,17 @@ namespace SpacetimeDB [DataMember(Name = "test_c")] public SpacetimeDB.Namespace.Types.TestC? TestC; + public TestD( + SpacetimeDB.Namespace.Types.TestC? TestC + ) + { + this.TestC = TestC; + } + + public TestD() + { + } + } } @@ -663,7 +771,21 @@ namespace SpacetimeDB [DataMember(Name = "id")] public ulong Id; [DataMember(Name = "name")] - public string Name = ""; + public string Name; + + public TestE( + ulong Id, + string Name + ) + { + this.Id = Id; + this.Name = Name; + } + + public TestE() + { + this.Name = ""; + } private static Dictionary Id_Index = new(16); diff --git a/crates/commitlog/LICENSE b/crates/commitlog/LICENSE deleted file mode 120000 index 1ef648f64b3..00000000000 --- a/crates/commitlog/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE.txt \ No newline at end of file diff --git a/crates/commitlog/LICENSE b/crates/commitlog/LICENSE new file mode 100644 index 00000000000..1ef648f64b3 --- /dev/null +++ b/crates/commitlog/LICENSE @@ -0,0 +1 @@ +../../LICENSE.txt \ No newline at end of file diff --git a/crates/durability/LICENSE b/crates/durability/LICENSE deleted file mode 120000 index 1ef648f64b3..00000000000 --- a/crates/durability/LICENSE +++ /dev/null @@ -1 +0,0 @@ -../../LICENSE.txt \ No newline at end of file diff --git a/crates/durability/LICENSE b/crates/durability/LICENSE new file mode 100644 index 00000000000..1ef648f64b3 --- /dev/null +++ b/crates/durability/LICENSE @@ -0,0 +1 @@ +../../LICENSE.txt \ No newline at end of file diff --git a/crates/lib/src/db/auth.rs b/crates/lib/src/db/auth.rs index b519d1b3a55..bf4989878d9 100644 --- a/crates/lib/src/db/auth.rs +++ b/crates/lib/src/db/auth.rs @@ -1,4 +1,4 @@ -use spacetimedb_sats::{impl_deserialize, impl_serialize}; +use spacetimedb_sats::{impl_deserialize, impl_serialize, impl_st, AlgebraicType}; use crate::de::Error; @@ -41,6 +41,7 @@ impl_deserialize!([] StAccess, de => { )) }) }); +impl_st!([] StAccess, _ts => AlgebraicType::String); /// Describe is the table is a `system table` or not. #[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] @@ -83,3 +84,4 @@ impl_deserialize!([] StTableType, de => { )) }) }); +impl_st!([] StTableType, _ts => AlgebraicType::String); diff --git a/crates/lib/src/db/raw_def/v8.rs b/crates/lib/src/db/raw_def/v8.rs index e1221367886..3555994f2cd 100644 --- a/crates/lib/src/db/raw_def/v8.rs +++ b/crates/lib/src/db/raw_def/v8.rs @@ -4,11 +4,10 @@ use crate::db::auth::{StAccess, StTableType}; use crate::relation::FieldName; -use crate::{AlgebraicType, ProductType}; +use crate::{AlgebraicType, ProductType, SpacetimeType}; use derive_more::Display; use spacetimedb_data_structures::map::HashSet; use spacetimedb_primitives::*; -use spacetimedb_sats::{de, ser}; // TODO(1.0): move these definitions into this file, // along with the other structs contained in it, @@ -23,7 +22,8 @@ pub use crate::RawModuleDefV8; pub const SEQUENCE_ALLOCATION_STEP: i128 = 4096; /// Represents a sequence definition for a database table column. -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub struct RawSequenceDefV8 { /// The name of the sequence. pub sequence_name: Box, @@ -80,7 +80,8 @@ impl RawSequenceDefV8 { /// Which type of index to create. /// /// Currently only `IndexType::BTree` is allowed. -#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Display, de::Deserialize, ser::Serialize)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Display, SpacetimeType)] +#[sats(crate = crate)] pub enum IndexType { /// A BTree index. BTree = 0, @@ -106,7 +107,8 @@ impl TryFrom for IndexType { } /// A struct representing the definition of a database index. -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub struct RawIndexDefV8 { /// The name of the index. /// This should not be assumed to follow any particular format. @@ -169,7 +171,8 @@ impl RawIndexDefV8 { } /// A struct representing the definition of a database column. -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub struct RawColumnDefV8 { /// The name of the column. pub col_name: Box, @@ -222,7 +225,8 @@ impl RawColumnDefV8 { /// A struct representing the definition of a database constraint. /// Associated with a unique `TableDef`, the one that contains it. -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub struct RawConstraintDefV8 { /// The name of the constraint. pub constraint_name: Box, @@ -302,7 +306,8 @@ pub fn generate_cols_name<'a>(columns: &ColList, col_name: impl Fn(ColId) -> Opt /// /// This struct holds information about the table, including its name, columns, indexes, /// constraints, sequences, type, and access rights. -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub struct RawTableDefV8 { /// The name of the table. pub table_name: Box, diff --git a/crates/lib/src/db/raw_def/v9.rs b/crates/lib/src/db/raw_def/v9.rs index e60581c8890..99ffcf05dbc 100644 --- a/crates/lib/src/db/raw_def/v9.rs +++ b/crates/lib/src/db/raw_def/v9.rs @@ -17,7 +17,7 @@ use spacetimedb_sats::AlgebraicTypeRef; use spacetimedb_sats::ProductType; use spacetimedb_sats::ProductTypeElement; use spacetimedb_sats::SpacetimeType; -use spacetimedb_sats::{de, ser, Typespace}; +use spacetimedb_sats::Typespace; use crate::db::auth::StAccess; use crate::db::auth::StTableType; @@ -48,7 +48,8 @@ pub type RawIdentifier = Box; /// /// All of these types of objects must have unique names within the module. /// The exception is columns, which need unique names only within a table. -#[derive(Debug, Clone, Default, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Default, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawModuleDefV9 { /// The `Typespace` used by the module. @@ -90,7 +91,8 @@ pub struct RawModuleDefV9 { /// - The table's indexes, constraints, and sequences need not be sorted; they will be sorted according to their respective ordering rules. /// - The table's column types may refer only to types in the containing RawDatabaseDef's typespace. /// - The table's column names must be unique. -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawTableDefV9 { /// The name of the table. @@ -134,7 +136,8 @@ pub struct RawTableDefV9 { } /// Whether the table was created by the system or the user. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub enum TableType { /// Created by the system. System, @@ -159,7 +162,8 @@ impl From for StTableType { } /// The visibility of the table. -#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub enum TableAccess { /// Visible to all Public, @@ -184,7 +188,8 @@ impl From for StAccess { } /// A sequence definition for a database table column. -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawSequenceDefV9 { /// The name of the sequence. Must be unique within the containing `RawDatabaseDef`. @@ -214,7 +219,8 @@ pub struct RawSequenceDefV9 { } /// The definition of a database index. -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawIndexDefV9 { /// The name of the index. @@ -242,7 +248,8 @@ pub struct RawIndexDefV9 { /// Data specifying an index algorithm. #[non_exhaustive] -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub enum RawIndexAlgorithm { /// Implemented using a B-Tree. @@ -262,7 +269,8 @@ pub enum RawIndexAlgorithm { /// Requires that the projection of the table onto these `columns` is a bijection. /// /// That is, there must be a one-to-one relationship between a row and the `columns` of that row. -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawUniqueConstraintDefV9 { /// The name of the unique constraint. Must be unique within the containing `RawDatabaseDef`. @@ -277,7 +285,8 @@ pub struct RawUniqueConstraintDefV9 { /// The table must have columns: /// - `scheduled_id` of type `u64`. /// - `scheduled_at` of type `ScheduleAt`. -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawScheduleDefV9 { /// The name of the schedule. Must be unique within the containing `RawDatabaseDef`. @@ -288,7 +297,8 @@ pub struct RawScheduleDefV9 { } /// A miscellaneous module export. -#[derive(Debug, Clone, ser::Serialize, de::Deserialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] #[non_exhaustive] pub enum RawMiscModuleExportV9 {} @@ -296,7 +306,8 @@ pub enum RawMiscModuleExportV9 {} /// A type declaration. /// /// Exactly of these must be attached to every `Product` and `Sum` type used by a module. -#[derive(Debug, Clone, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawTypeDefV9 { /// The name of the type declaration. @@ -313,7 +324,8 @@ pub struct RawTypeDefV9 { /// /// These are the names that will be used *in client code generation*, NOT the names used for types /// in the module source code. -#[derive(Clone, de::Deserialize, ser::Serialize, PartialEq, Eq, PartialOrd, Ord)] +#[derive(Clone, SpacetimeType, PartialEq, Eq, PartialOrd, Ord)] +#[sats(crate = crate)] pub struct RawScopedTypeNameV9 { /// The scope for this type. /// @@ -339,7 +351,8 @@ impl fmt::Debug for RawScopedTypeNameV9 { } /// A reducer definition. -#[derive(Debug, Clone, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] pub struct RawReducerDefV9 { /// The name of the reducer. @@ -354,7 +367,8 @@ pub struct RawReducerDefV9 { } /// Special roles a reducer can play in the module lifecycle. -#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, SpacetimeType)] +#[sats(crate = crate)] #[non_exhaustive] pub enum Lifecycle { /// The reducer will be invoked upon module initialization. diff --git a/crates/lib/src/lib.rs b/crates/lib/src/lib.rs index 196cb35c9b4..b895660c3c5 100644 --- a/crates/lib/src/lib.rs +++ b/crates/lib/src/lib.rs @@ -83,7 +83,8 @@ impl std::fmt::Display for VersionTuple { extern crate self as spacetimedb_lib; //WARNING: Change this structure(or any of their members) is an ABI change. -#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, SpacetimeType)] +#[sats(crate = crate)] pub struct TableDesc { pub schema: RawTableDefV8, /// data should always point to a ProductType in the typespace @@ -107,7 +108,8 @@ impl TableDesc { } } -#[derive(Debug, Clone, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] pub struct ReducerDef { pub name: Box, pub args: Vec, @@ -176,7 +178,8 @@ impl_serialize!([] ReducerArgsWithSchema<'_>, (self, ser) => { }); //WARNING: Change this structure(or any of their members) is an ABI change. -#[derive(Debug, Clone, Default, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, Default, SpacetimeType)] +#[sats(crate = crate)] pub struct RawModuleDefV8 { pub typespace: sats::Typespace, pub tables: Vec, @@ -199,7 +202,8 @@ impl RawModuleDefV8 { /// A versioned raw module definition. /// /// This is what is actually returned by the module when `__describe_module__` is called, serialized to BSATN. -#[derive(Debug, Clone, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] #[non_exhaustive] pub enum RawModuleDef { V8BackCompat(RawModuleDefV8), @@ -321,12 +325,14 @@ impl TypespaceBuilder for ModuleDefBuilder { } // an enum to keep it extensible without breaking abi -#[derive(Debug, Clone, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] pub enum MiscModuleExport { TypeAlias(TypeAlias), } -#[derive(Debug, Clone, de::Deserialize, ser::Serialize)] +#[derive(Debug, Clone, SpacetimeType)] +#[sats(crate = crate)] pub struct TypeAlias { pub name: String, pub ty: sats::AlgebraicTypeRef, diff --git a/crates/sats/src/algebraic_type.rs b/crates/sats/src/algebraic_type.rs index 8f81a07d94f..ec69c741d6d 100644 --- a/crates/sats/src/algebraic_type.rs +++ b/crates/sats/src/algebraic_type.rs @@ -3,12 +3,14 @@ pub mod map_notation; use crate::algebraic_value::de::{ValueDeserializeError, ValueDeserializer}; use crate::algebraic_value::ser::value_serialize; +use crate::de::Deserialize; use crate::meta_type::MetaType; use crate::product_type::{ADDRESS_TAG, IDENTITY_TAG}; use crate::sum_type::{OPTION_NONE_TAG, OPTION_SOME_TAG}; -use crate::{de::Deserialize, ser::Serialize, MapType}; use crate::{i256, u256}; -use crate::{AlgebraicTypeRef, AlgebraicValue, ArrayType, ProductType, SumType, SumTypeVariant}; +use crate::{ + AlgebraicTypeRef, AlgebraicValue, ArrayType, MapType, ProductType, SpacetimeType, SumType, SumTypeVariant, +}; use derive_more::From; use enum_as_inner::EnumAsInner; @@ -18,7 +20,7 @@ use enum_as_inner::EnumAsInner; /// The type system unifies the concepts sum types, product types, scalar value types, /// and convenience types strings, arrays, and maps, /// into a single type system. -#[derive(EnumAsInner, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, From)] +#[derive(EnumAsInner, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, SpacetimeType, From)] #[sats(crate = crate)] pub enum AlgebraicType { /// A type where the definition is given by the typing context (`Typespace`). diff --git a/crates/sats/src/algebraic_type_ref.rs b/crates/sats/src/algebraic_type_ref.rs index bb7ac53f51a..554eb69b67c 100644 --- a/crates/sats/src/algebraic_type_ref.rs +++ b/crates/sats/src/algebraic_type_ref.rs @@ -1,3 +1,4 @@ +use crate::impl_st; use crate::{algebraic_type::AlgebraicType, impl_deserialize, impl_serialize, meta_type::MetaType}; use std::fmt::Display; @@ -20,6 +21,7 @@ impl AlgebraicTypeRef { impl_serialize!([] AlgebraicTypeRef, (self, ser) => self.0.serialize(ser)); impl_deserialize!([] AlgebraicTypeRef, de => u32::deserialize(de).map(Self)); +impl_st!([] AlgebraicTypeRef, _ts => AlgebraicType::U32); impl Display for AlgebraicTypeRef { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { diff --git a/crates/sats/src/array_type.rs b/crates/sats/src/array_type.rs index 2075515ec25..2a193c8091b 100644 --- a/crates/sats/src/array_type.rs +++ b/crates/sats/src/array_type.rs @@ -1,7 +1,7 @@ use crate::algebraic_type::AlgebraicType; use crate::de::Deserialize; use crate::meta_type::MetaType; -use crate::{impl_deserialize, impl_serialize}; +use crate::{impl_deserialize, impl_serialize, impl_st}; /// An array type is a homegeneous product type of dynamic length. /// @@ -16,6 +16,7 @@ pub struct ArrayType { impl_serialize!([] ArrayType, (self, ser) => self.elem_ty.serialize(ser)); impl_deserialize!([] ArrayType, de => Deserialize::deserialize(de).map(|elem_ty| Self { elem_ty })); +impl_st!([] ArrayType, ts => AlgebraicType::make_type(ts)); impl MetaType for ArrayType { fn meta_type() -> AlgebraicType { diff --git a/crates/sats/src/map_type.rs b/crates/sats/src/map_type.rs index 8b9ba7fbc32..45665ab8d0c 100644 --- a/crates/sats/src/map_type.rs +++ b/crates/sats/src/map_type.rs @@ -1,7 +1,7 @@ -use crate::{de::Deserialize, meta_type::MetaType, ser::Serialize, AlgebraicType}; +use crate::{meta_type::MetaType, AlgebraicType, SpacetimeType}; /// A map type from keys of type `key_ty` to values of type `ty`. -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, SpacetimeType)] #[sats(crate = crate)] pub struct MapType { /// The key type of the map. diff --git a/crates/sats/src/primitives.rs b/crates/sats/src/primitives.rs index 44702ed6eea..e3b6462d27b 100644 --- a/crates/sats/src/primitives.rs +++ b/crates/sats/src/primitives.rs @@ -1,4 +1,4 @@ -use crate::{de, impl_deserialize, impl_serialize}; +use crate::{de, impl_deserialize, impl_serialize, impl_st, AlgebraicType}; pub use spacetimedb_primitives::ColumnAttribute; pub use spacetimedb_primitives::Constraints; @@ -6,10 +6,11 @@ impl_deserialize!([] ColumnAttribute, de => Self::from_bits(de.deserialize_u8()?) .ok_or_else(|| de::Error::custom("invalid bitflags for `ColumnAttribute`")) ); - impl_serialize!([] ColumnAttribute, (self, ser) => ser.serialize_u8(self.bits())); +impl_st!([] ColumnAttribute, _ts => AlgebraicType::U8); impl_deserialize!([] Constraints, de => Self::try_from(de.deserialize_u8()?) .map_err(|_| de::Error::custom("invalid bitflags for `Constraints`")) ); impl_serialize!([] Constraints, (self, ser) => ser.serialize_u8(self.bits())); +impl_st!([] Constraints, _ts => AlgebraicType::U8); diff --git a/crates/sats/src/product_type.rs b/crates/sats/src/product_type.rs index 8bbfd913cb8..73babc5ed52 100644 --- a/crates/sats/src/product_type.rs +++ b/crates/sats/src/product_type.rs @@ -1,8 +1,8 @@ use crate::algebraic_value::de::{ValueDeserializeError, ValueDeserializer}; use crate::algebraic_value::ser::value_serialize; +use crate::de::Deserialize; use crate::meta_type::MetaType; -use crate::{de::Deserialize, ser::Serialize}; -use crate::{AlgebraicType, AlgebraicValue, ProductTypeElement, ValueWithType, WithTypespace}; +use crate::{AlgebraicType, AlgebraicValue, ProductTypeElement, SpacetimeType, ValueWithType, WithTypespace}; /// The tag used inside the special `Identity` product type. pub const IDENTITY_TAG: &str = "__identity_bytes"; @@ -32,7 +32,7 @@ pub const ADDRESS_TAG: &str = "__address_bytes"; /// so for example, `values({ A: U64, B: Bool }) = values(U64) * values(Bool)`. /// /// [structural]: https://en.wikipedia.org/wiki/Structural_type_system -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, SpacetimeType)] #[sats(crate = crate)] pub struct ProductType { /// The factors of the product type. diff --git a/crates/sats/src/product_type_element.rs b/crates/sats/src/product_type_element.rs index 27f40110157..1a581e5e571 100644 --- a/crates/sats/src/product_type_element.rs +++ b/crates/sats/src/product_type_element.rs @@ -1,6 +1,5 @@ use crate::meta_type::MetaType; -use crate::{de::Deserialize, ser::Serialize}; -use crate::{AlgebraicType, WithTypespace}; +use crate::{AlgebraicType, SpacetimeType, WithTypespace}; /// A factor / element of a product type. /// @@ -8,7 +7,7 @@ use crate::{AlgebraicType, WithTypespace}; /// /// NOTE: Each element has an implicit element tag based on its order. /// Uniquely identifies an element similarly to protobuf tags. -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, SpacetimeType)] #[sats(crate = crate)] pub struct ProductTypeElement { /// The name of the field / element. diff --git a/crates/sats/src/ser/impls.rs b/crates/sats/src/ser/impls.rs index 2dd54e0b42f..8ae4779060e 100644 --- a/crates/sats/src/ser/impls.rs +++ b/crates/sats/src/ser/impls.rs @@ -1,7 +1,8 @@ use super::{Serialize, SerializeArray, SerializeMap, SerializeNamedProduct, SerializeSeqProduct, Serializer}; use crate::{i256, u256}; use crate::{ - AlgebraicType, AlgebraicValue, ArrayValue, MapType, MapValue, ProductValue, SumValue, ValueWithType, F32, F64, + impl_st, AlgebraicType, AlgebraicValue, ArrayValue, MapType, MapValue, ProductValue, SumValue, ValueWithType, F32, + F64, }; use spacetimedb_primitives::ColList; use std::collections::BTreeMap; @@ -251,6 +252,8 @@ impl_serialize!([] ColList, (self, ser) => { arr.end() }); +impl_st!([] ColList, ts => AlgebraicType::array(spacetimedb_primitives::ColId::make_type(ts))); + #[cfg(feature = "blake3")] impl_serialize!([] blake3::Hash, (self, ser) => self.as_bytes().serialize(ser)); diff --git a/crates/sats/src/sum_type.rs b/crates/sats/src/sum_type.rs index b6a00ddfff4..b035f9dc25c 100644 --- a/crates/sats/src/sum_type.rs +++ b/crates/sats/src/sum_type.rs @@ -1,8 +1,8 @@ use crate::algebraic_value::de::{ValueDeserializeError, ValueDeserializer}; use crate::algebraic_value::ser::value_serialize; +use crate::de::Deserialize; use crate::meta_type::MetaType; -use crate::{de::Deserialize, ser::Serialize}; -use crate::{AlgebraicType, AlgebraicValue, SumTypeVariant}; +use crate::{AlgebraicType, AlgebraicValue, SpacetimeType, SumTypeVariant}; /// The tag used for the `Interval` variant of the special `ScheduleAt` sum type. pub const SCHEDULE_AT_INTERVAL_TAG: &str = "Interval"; @@ -37,7 +37,7 @@ pub const OPTION_NONE_TAG: &str = "none"; /// See also: https://ncatlab.org/nlab/show/sum+type. /// /// [structural]: https://en.wikipedia.org/wiki/Structural_type_system -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, SpacetimeType)] #[sats(crate = crate)] pub struct SumType { /// The possible variants of the sum type. diff --git a/crates/sats/src/sum_type_variant.rs b/crates/sats/src/sum_type_variant.rs index ea67d97c4c3..b11044e7cd9 100644 --- a/crates/sats/src/sum_type_variant.rs +++ b/crates/sats/src/sum_type_variant.rs @@ -1,12 +1,12 @@ use crate::algebraic_type::AlgebraicType; use crate::meta_type::MetaType; -use crate::{de::Deserialize, ser::Serialize}; +use crate::SpacetimeType; /// A variant of a sum type. /// /// NOTE: Each element has an implicit element tag based on its order. /// Uniquely identifies an element similarly to protobuf tags. -#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)] +#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, SpacetimeType)] #[sats(crate = crate)] pub struct SumTypeVariant { /// The name of the variant, if any. diff --git a/crates/sats/src/typespace.rs b/crates/sats/src/typespace.rs index f05ee54cabd..b7802a8f446 100644 --- a/crates/sats/src/typespace.rs +++ b/crates/sats/src/typespace.rs @@ -4,7 +4,6 @@ use std::ops::{Index, IndexMut}; use crate::algebraic_type::AlgebraicType; use crate::algebraic_type_ref::AlgebraicTypeRef; use crate::WithTypespace; -use crate::{de::Deserialize, ser::Serialize}; /// An error that occurs when attempting to resolve a type. #[derive(thiserror::Error, Debug, PartialOrd, Ord, PartialEq, Eq)] @@ -34,7 +33,7 @@ pub enum TypeRefError { /// where `&0` is the type reference at index `0`. /// /// [System F]: https://en.wikipedia.org/wiki/System_F -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, SpacetimeType)] #[cfg_attr(feature = "test", derive(PartialEq, Eq, PartialOrd, Ord))] #[sats(crate = crate)] pub struct Typespace { @@ -228,12 +227,6 @@ pub trait SpacetimeType { fn make_type(typespace: &mut S) -> AlgebraicType; } -impl SpacetimeType for T { - fn make_type(_: &mut S) -> AlgebraicType { - T::get_type() - } -} - use ethnum::{i256, u256}; pub use spacetimedb_bindings_macro::SpacetimeType; @@ -273,15 +266,21 @@ pub trait TypespaceBuilder { /// ``` #[macro_export] macro_rules! impl_st { - ([ $($rgenerics:tt)* ] $rty:ty, $stty:expr) => { - impl<$($rgenerics)*> $crate::GroundSpacetimeType for $rty { + ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $stty:expr) => { + impl<$($generic_wrapped $($other_generics)*)?> $crate::GroundSpacetimeType for $rty + $(where $generic_wrapped: $crate::GroundSpacetimeType)? + { fn get_type() -> $crate::AlgebraicType { $stty } } + + impl_st!([ $($generic $($other_generics)*)? ] $rty, _ts => $stty); }; - ([ $($rgenerics:tt)* ] $rty:ty, $ts:ident => $stty:expr) => { - impl<$($rgenerics)*> $crate::SpacetimeType for $rty { + ([ $($generic_wrapped:ident $($other_generics:tt)*)? ] $rty:ty, $ts:ident => $stty:expr) => { + impl<$($generic_wrapped $($other_generics)*)?> $crate::SpacetimeType for $rty + $(where $generic_wrapped: $crate::SpacetimeType)? + { fn make_type($ts: &mut S) -> $crate::AlgebraicType { $stty } @@ -315,9 +314,11 @@ impl_primitives! { } impl_st!([](), AlgebraicType::unit()); -impl_st!([] & str, AlgebraicType::String); -impl_st!([T: SpacetimeType] Vec, ts => AlgebraicType::array(T::make_type(ts))); -impl_st!([T: SpacetimeType] Option, ts => AlgebraicType::option(T::make_type(ts))); +impl_st!([] str, AlgebraicType::String); +impl_st!([T] [T], ts => AlgebraicType::array(T::make_type(ts))); +impl_st!([T: ?Sized] Box, ts => T::make_type(ts)); +impl_st!([T] Vec, ts => <[T]>::make_type(ts)); +impl_st!([T] Option, ts => AlgebraicType::option(T::make_type(ts))); impl_st!([] spacetimedb_primitives::ColId, AlgebraicType::U16); impl_st!([] spacetimedb_primitives::TableId, AlgebraicType::U32); diff --git a/crates/sdk/examples/cursive-chat/module_bindings/message.rs b/crates/sdk/examples/cursive-chat/module_bindings/message.rs deleted file mode 120000 index 1dc7f89c37d..00000000000 --- a/crates/sdk/examples/cursive-chat/module_bindings/message.rs +++ /dev/null @@ -1 +0,0 @@ -../../quickstart-chat/module_bindings/message.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/message.rs b/crates/sdk/examples/cursive-chat/module_bindings/message.rs new file mode 100644 index 00000000000..1dc7f89c37d --- /dev/null +++ b/crates/sdk/examples/cursive-chat/module_bindings/message.rs @@ -0,0 +1 @@ +../../quickstart-chat/module_bindings/message.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/mod.rs b/crates/sdk/examples/cursive-chat/module_bindings/mod.rs deleted file mode 120000 index c3ca974338f..00000000000 --- a/crates/sdk/examples/cursive-chat/module_bindings/mod.rs +++ /dev/null @@ -1 +0,0 @@ -../../quickstart-chat/module_bindings/mod.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/mod.rs b/crates/sdk/examples/cursive-chat/module_bindings/mod.rs new file mode 100644 index 00000000000..c3ca974338f --- /dev/null +++ b/crates/sdk/examples/cursive-chat/module_bindings/mod.rs @@ -0,0 +1 @@ +../../quickstart-chat/module_bindings/mod.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs b/crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs deleted file mode 120000 index cc1b8b85c34..00000000000 --- a/crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs +++ /dev/null @@ -1 +0,0 @@ -../../quickstart-chat/module_bindings/send_message_reducer.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs b/crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs new file mode 100644 index 00000000000..cc1b8b85c34 --- /dev/null +++ b/crates/sdk/examples/cursive-chat/module_bindings/send_message_reducer.rs @@ -0,0 +1 @@ +../../quickstart-chat/module_bindings/send_message_reducer.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs b/crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs deleted file mode 120000 index 20bc23a3ac1..00000000000 --- a/crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs +++ /dev/null @@ -1 +0,0 @@ -../../quickstart-chat/module_bindings/set_name_reducer.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs b/crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs new file mode 100644 index 00000000000..20bc23a3ac1 --- /dev/null +++ b/crates/sdk/examples/cursive-chat/module_bindings/set_name_reducer.rs @@ -0,0 +1 @@ +../../quickstart-chat/module_bindings/set_name_reducer.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/user.rs b/crates/sdk/examples/cursive-chat/module_bindings/user.rs deleted file mode 120000 index 8a8a50a8c30..00000000000 --- a/crates/sdk/examples/cursive-chat/module_bindings/user.rs +++ /dev/null @@ -1 +0,0 @@ -../../quickstart-chat/module_bindings/user.rs \ No newline at end of file diff --git a/crates/sdk/examples/cursive-chat/module_bindings/user.rs b/crates/sdk/examples/cursive-chat/module_bindings/user.rs new file mode 100644 index 00000000000..8a8a50a8c30 --- /dev/null +++ b/crates/sdk/examples/cursive-chat/module_bindings/user.rs @@ -0,0 +1 @@ +../../quickstart-chat/module_bindings/user.rs \ No newline at end of file