Skip to content

Commit cb35104

Browse files
rekhoffJasonAtClockworkjdetterjoshua-spacetime
authored
Export __call_view__ in C# (#3691)
# Description of Changes 1. Updates the Replication Tests in `sdks/csharp/examples~/regression-tests` to include better coverage of Views 2. Added missing linkage for __call_view__ and __call_view_anon__ 3. Updated *ViewDispatcher Invoke to transform BSATN.ValueOption<> into BSATN.List<> 4. Fixed issues with the indexing of views to match correctly during __call_view__ and __call_view_anon__ # API and ABI breaking changes No # Expected complexity level and risk 2 # Testing - [x] Running `run-regression-tests.sh` passes. --------- Signed-off-by: rekhoff <[email protected]> Signed-off-by: Jason Larabie <[email protected]> Co-authored-by: Jason Larabie <[email protected]> Co-authored-by: John Detter <[email protected]> Co-authored-by: joshua-spacetime <[email protected]>
1 parent 6b43769 commit cb35104

File tree

21 files changed

+768
-216
lines changed

21 files changed

+768
-216
lines changed

crates/bindings-csharp/BSATN.Runtime/BSATN/Runtime.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ public void Write(BinaryWriter writer, Inner? value)
228228

229229
public AlgebraicType GetAlgebraicType(ITypeRegistrar registrar) =>
230230
AlgebraicType.MakeOption(innerRW.GetAlgebraicType(registrar));
231+
232+
// Return a List BSATN serializer that can serialize this option as an array
233+
public static List<Inner, InnerRW> GetListSerializer()
234+
{
235+
return new List<Inner, InnerRW>();
236+
}
231237
}
232238

233239
public readonly struct Bool : IReadWrite<bool>

crates/bindings-csharp/Codegen.Tests/fixtures/diag/snapshots/ExtraCompilationErrors.verified.txt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public partial struct TestDefaultFieldValues
233233

234234
var returnValue = Module.ViewDefWrongContext((SpacetimeDB.ViewContext)ctx);
235235
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
236-
using var output = new System.IO.MemoryStream();
236+
SpacetimeDB.BSATN.List<Player, Player.BSATN> returnRW = new();
237237
*/
238238
Message: Argument 1: cannot convert from 'SpacetimeDB.ViewContext' to 'SpacetimeDB.ReducerContext',
239239
Severity: Error,
@@ -279,7 +279,7 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
279279

280280
var returnValue = Module.ViewDefNoContext((SpacetimeDB.ViewContext)ctx);
281281
^^^^^^^^^^^^^^^^
282-
using var output = new System.IO.MemoryStream();
282+
SpacetimeDB.BSATN.List<Player, Player.BSATN> returnRW = new();
283283
*/
284284
Message: No overload for method 'ViewDefNoContext' takes 1 arguments,
285285
Severity: Error,
@@ -299,10 +299,10 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
299299
}
300300
},
301301
{/*
302-
303-
private static readonly SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN> returnRW = new();
304-
^^^^^
305-
302+
Params: [],
303+
ReturnType: new SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>().GetAlgebraicType(registrar)
304+
^^^^^
305+
);
306306
*/
307307
Message: The type name 'BSATN' does not exist in the type 'NotSpacetimeType',
308308
Severity: Error,
@@ -322,10 +322,10 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
322322
}
323323
},
324324
{/*
325-
Params: [],
326-
ReturnType: new SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>().GetAlgebraicType(registrar)
327-
^^^^^
328-
);
325+
var returnValue = Module.ViewDefReturnsNotASpacetimeType((SpacetimeDB.AnonymousViewContext)ctx);
326+
var listSerializer = SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>.GetListSerializer();
327+
^^^^^
328+
var listValue = ModuleRegistration.ToListOrEmpty(returnValue);
329329
*/
330330
Message: The type name 'BSATN' does not exist in the type 'NotSpacetimeType',
331331
Severity: Error,

0 commit comments

Comments
 (0)