Skip to content

Commit 87de672

Browse files
JasonAtClockworkjdetterjoshua-spacetimerekhoff
authored
Fix C# module bindings codegen for namespaces with view dispatcher (#3668)
# Description of Changes Closes: #3658 With the work on Views we ran into trouble with the Return Type and certain C# code layout where the types are defined inside the Module class. This fixes the bug in our current approach but needs consideration to possibly be changed entirely. # API and ABI breaking changes N/A # Expected complexity level and risk 1 - Minor change # Testing - [x] Retested with the linked code with and without the namespace - [x] Re-ran regression tests --------- Co-authored-by: John Detter <[email protected]> Co-authored-by: joshua-spacetime <[email protected]> Co-authored-by: rekhoff <[email protected]>
1 parent ca2fd8b commit 87de672

File tree

5 files changed

+28
-18
lines changed

5 files changed

+28
-18
lines changed

crates/bindings-csharp/Codegen/Module.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -997,10 +997,7 @@ public string GenerateViewDef(uint Index) =>
997997
IsPublic: {{{IsPublic.ToString().ToLower()}}},
998998
IsAnonymous: {{{IsAnonymous.ToString().ToLower()}}},
999999
Params: [{{{MemberDeclaration.GenerateDefs(Parameters)}}}],
1000-
ReturnType: new {{{ReturnType.BSATNName.Replace(
1001-
"Module.",
1002-
"global::Module."
1003-
)}}}().GetAlgebraicType(registrar)
1000+
ReturnType: new {{{ReturnType.BSATNName}}}().GetAlgebraicType(registrar)
10041001
);
10051002
""";
10061003

modules/sdk-test-cs/Lib.cs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,12 @@ public static void insert_unique_u32(ReducerContext ctx, uint n, int data)
848848
}
849849

850850
[SpacetimeDB.Reducer]
851-
public static void insert_unique_u32_update_pk_u32(ReducerContext ctx, uint n, int d_unique, int d_pk)
851+
public static void insert_unique_u32_update_pk_u32(
852+
ReducerContext ctx,
853+
uint n,
854+
int d_unique,
855+
int d_pk
856+
)
852857
{
853858
ctx.Db.unique_u32.Insert(new UniqueU32 { n = n, data = d_unique });
854859
ctx.Db.pk_u32.n.Update(new PkU32 { n = n, data = d_pk });
@@ -1715,9 +1720,7 @@ public static void insert_caller_one_identity(ReducerContext ctx)
17151720
[SpacetimeDB.Reducer]
17161721
public static void insert_caller_vec_identity(ReducerContext ctx)
17171722
{
1718-
ctx.Db.vec_identity.Insert(
1719-
new VecIdentity { i = new List<Identity> { ctx.Sender } }
1720-
);
1723+
ctx.Db.vec_identity.Insert(new VecIdentity { i = new List<Identity> { ctx.Sender } });
17211724
}
17221725

17231726
[SpacetimeDB.Reducer]
@@ -1735,7 +1738,9 @@ public static void insert_caller_pk_identity(ReducerContext ctx, int data)
17351738
[SpacetimeDB.Reducer]
17361739
public static void insert_caller_one_connection_id(ReducerContext ctx)
17371740
{
1738-
ctx.Db.one_connection_id.Insert(new OneConnectionId { a = (ConnectionId)ctx.ConnectionId! });
1741+
ctx.Db.one_connection_id.Insert(
1742+
new OneConnectionId { a = (ConnectionId)ctx.ConnectionId! }
1743+
);
17391744
}
17401745

17411746
[SpacetimeDB.Reducer]
@@ -1753,14 +1758,16 @@ public static void insert_caller_vec_connection_id(ReducerContext ctx)
17531758
public static void insert_caller_unique_connection_id(ReducerContext ctx, int data)
17541759
{
17551760
ctx.Db.unique_connection_id.Insert(
1756-
new UniqueConnectionId { a = (ConnectionId)ctx.ConnectionId!, data = data }
1761+
new UniqueConnectionId { a = (ConnectionId)ctx.ConnectionId!, data = data }
17571762
);
17581763
}
17591764

17601765
[SpacetimeDB.Reducer]
17611766
public static void insert_caller_pk_connection_id(ReducerContext ctx, int data)
17621767
{
1763-
ctx.Db.pk_connection_id.Insert(new PkConnectionId { a = (ConnectionId)ctx.ConnectionId!, data = data });
1768+
ctx.Db.pk_connection_id.Insert(
1769+
new PkConnectionId { a = (ConnectionId)ctx.ConnectionId!, data = data }
1770+
);
17641771
}
17651772

17661773
[SpacetimeDB.Reducer]
@@ -1782,7 +1789,11 @@ public static void delete_from_btree_u32(ReducerContext ctx, List<BTreeU32> rows
17821789
}
17831790

17841791
[SpacetimeDB.Reducer]
1785-
public static void insert_into_pk_btree_u32(ReducerContext ctx, List<PkU32> pk_u32, List<BTreeU32> bt_u32)
1792+
public static void insert_into_pk_btree_u32(
1793+
ReducerContext ctx,
1794+
List<PkU32> pk_u32,
1795+
List<BTreeU32> bt_u32
1796+
)
17861797
{
17871798
foreach (var row in pk_u32)
17881799
{
@@ -1950,7 +1961,6 @@ public static void insert_primitives_as_strings(ReducerContext ctx, EveryPrimiti
19501961
return value.ToString()!.ToLowerInvariant();
19511962
}
19521963
return value.ToString()!;
1953-
19541964
})
19551965
.ToList(),
19561966
}
@@ -2032,7 +2042,9 @@ public partial struct BTreeU32
20322042
}
20332043

20342044
[SpacetimeDB.ClientVisibilityFilter]
2035-
public static readonly Filter USERS_FILTER = new Filter.Sql("SELECT * FROM users WHERE identity = :sender");
2045+
public static readonly Filter USERS_FILTER = new Filter.Sql(
2046+
"SELECT * FROM users WHERE identity = :sender"
2047+
);
20362048

20372049
[SpacetimeDB.Table(Name = "users", Public = true)]
20382050
public partial struct Users
@@ -2049,7 +2061,8 @@ public static void insert_user(ReducerContext ctx, string name, Identity identit
20492061
}
20502062

20512063
[SpacetimeDB.Table(Name = "indexed_simple_enum", Public = true)]
2052-
public partial struct IndexedSimpleEnum {
2064+
public partial struct IndexedSimpleEnum
2065+
{
20532066
[SpacetimeDB.Index.BTree]
20542067
public SimpleEnum n;
20552068
}

sdks/csharp/examples~/quickstart-chat/client/module_bindings/SpacetimeDBClient.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/csharp/examples~/regression-tests/republishing/client/module_bindings/SpacetimeDBClient.g.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdks/rust/tests/test-client/src/module_bindings/mod.rs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)