Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ef6139b
Renamed CSharp Codegen TableViews to TableAccessors to give space to …
rekhoff Oct 24, 2025
f7c93b7
C3 View Bindings Pass 1
rekhoff Nov 3, 2025
f860d9a
Updated with additional changes and reworks
rekhoff Nov 5, 2025
cf5cb74
RegisterView fixed, removed ViewStubs as separate files, suppressed `…
rekhoff Nov 5, 2025
e854163
Cleaned up unneeded includes and code paths
rekhoff Nov 5, 2025
2c3032f
Corrected RegisterView to use existing TypeRegistrar
rekhoff Nov 5, 2025
6f30ca5
Adding new ViewDispatchers during registration
rekhoff Nov 5, 2025
af3f85d
Merge branch 'master' into rekhoff/csharp-view-bindings
rekhoff Nov 5, 2025
1c472ee
Fixes for module-test-cs to match the Rust view work
JasonAtClockwork Nov 6, 2025
16ba57a
Several fixes for CI and small bug on visibility for readonly accessors
JasonAtClockwork Nov 6, 2025
2b20e6d
Generate missing updates on ClientApi, Quickstart, and Regression
JasonAtClockwork Nov 6, 2025
686497c
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 6, 2025
7ac69be
Update ensure_same_schema test to skip UpdateView for C#
JasonAtClockwork Nov 6, 2025
6ba4684
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 6, 2025
1edcd7d
Add error descriptors for View name requirement and public forced to …
JasonAtClockwork Nov 7, 2025
ddfa44a
Update module test cs to properly label the View
JasonAtClockwork Nov 7, 2025
d5a3830
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 7, 2025
97a1528
Add handling of View Indexes
JasonAtClockwork Nov 7, 2025
cfb6bbb
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 7, 2025
dba2007
Remove View arguments beyond the ViewContext
JasonAtClockwork Nov 7, 2025
467ec72
Merge branch 'rekhoff/csharp-view-bindings' of https://github.com/clo…
JasonAtClockwork Nov 7, 2025
f01df57
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 7, 2025
7f47751
Removed IsAnonymous from the [View] attribute and left it to inferrin…
JasonAtClockwork Nov 7, 2025
589de98
Removed GetIdentity() from IAnonymousViewContext, added ErrorDescript…
JasonAtClockwork Nov 8, 2025
ea81748
Removed Delete() from ReadOnly Indexes (no other mutations were previ…
JasonAtClockwork Nov 8, 2025
61bf89a
Removed improper using
JasonAtClockwork Nov 8, 2025
3d77f93
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 10, 2025
6ffdb14
Merge branch 'master' into rekhoff/csharp-view-bindings
JasonAtClockwork Nov 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions crates/bindings-csharp/Codegen.Tests/fixtures/diag/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ public partial struct TestScheduleIssues
public static void DummyScheduledReducer(ReducerContext ctx, TestScheduleIssues table) { }
}

[SpacetimeDB.Table]
public partial struct Player
{
[Unique]
public Identity Identity;
}

public struct NotSpacetimeType { }

public partial class Module
{
#pragma warning disable STDB_UNSTABLE // Enable ClientVisibilityFilter
Expand All @@ -506,4 +515,84 @@ public partial class Module
public static readonly Filter MY_FOURTH_FILTER = new Filter.Sql(
"SELECT * FROM TestAutoIncNotInteger"
);

// Invalid: View definition missing Public=true
[SpacetimeDB.View(Name = "view_def_no_public")]
public static List<Player> ViewDefNoPublic(ViewContext ctx)
{
return new List<Player>();
}

// Invalid: View definition with missing context type
[SpacetimeDB.View(Name = "view_def_no_context", Public = true)]
public static List<Player> ViewDefNoContext()
{
return new List<Player>();
}

// Invalid: View definition with wrong context type
[SpacetimeDB.View(Name = "view_def_wrong_context", Public = true)]
public static List<Player> ViewDefWrongContext(ReducerContext ctx)
{
return new List<Player>();
}

// Invalid: View that performs Insert
[SpacetimeDB.View(Name = "view_no_insert", Public = true)]
public static Player? ViewNoInsert(ViewContext ctx)
{
ctx.Db.Player.Insert(new Player { Identity = new() });
return new Player { Identity = new() };
}

// Invalid: View that performs Delete
[SpacetimeDB.View(Name = "view_no_delete", Public = true)]
public static Player? ViewNoDelete(ViewContext ctx)
{
ctx.Db.Player.Delete(new Player { Identity = new() });
return null;
}

// TODO: Investigate why void return breaks the FFI generation
// // Invalid: Void return type is not Vec<T> or Option<T>
// [SpacetimeDB.View(Name = "view_def_no_return", Public = true)]
// public static void ViewDefNoReturn(ViewContext ctx)
// {
// return;
// }

// Invalid: Wrong return type is not Vec<T> or Option<T>
[SpacetimeDB.View(Name = "view_def_wrong_return", Public = true)]
public static Player ViewDefWrongReturn(ViewContext ctx)
{
return new Player { Identity = new() };
}

// Invalid: Returns type that is not a SpacetimeType
[SpacetimeDB.View(Name = "view_def_returns_not_a_spacetime_type", Public = true)]
public static NotSpacetimeType? ViewDefReturnsNotASpacetimeType(AnonymousViewContext ctx)
{
return new NotSpacetimeType();
}

[SpacetimeDB.View(Name = "view_def_no_anon_identity", Public = true)]
public static Player? ViewDefNoAnonIdentity(AnonymousViewContext ctx)
{
ctx.GetIdentity();
return null;
}

[SpacetimeDB.View(Name = "view_def_no_iter", Public = true)]
public static Player? ViewDefNoIter(AnonymousViewContext ctx)
{
ctx.Db.Player.Iter();
return null;
}

[SpacetimeDB.View(Name = "view_def_index_no_mutation", Public = true)]
public static Player? ViewDefIndexNoMutation(AnonymousViewContext ctx)
{
ctx.Db.Player.Identity.Delete(0);
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,27 @@
[
{/*
{
ctx.GetIdentity();
^^^^^^^^^^^
return null;
*/
Message: 'AnonymousViewContext' does not contain a definition for 'GetIdentity' and no accessible extension method 'GetIdentity' accepting a first argument of type 'AnonymousViewContext' could be found (are you missing a using directive or an assembly reference?),
Severity: Error,
Descriptor: {
Id: CS1061,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1061),
MessageFormat: '{0}' does not contain a definition for '{1}' and no accessible extension method '{1}' accepting a first argument of type '{0}' could be found (are you missing a using directive or an assembly reference?),
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
SpacetimeDB.Internal.Module.RegisterTable<global::TestUniqueNotEquatable, SpacetimeDB.Internal.TableHandles.TestUniqueNotEquatable>();
SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_FILTER);
Expand All @@ -22,6 +45,98 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_FOU
]
}
},
{/*
{
ctx.Db.Player.Identity.Delete(0);
^^^^^^
return null;
*/
Message: 'PlayerReadOnly.IdentityIndex' does not contain a definition for 'Delete' and no accessible extension method 'Delete' accepting a first argument of type 'PlayerReadOnly.IdentityIndex' could be found (are you missing a using directive or an assembly reference?),
Severity: Error,
Descriptor: {
Id: CS1061,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1061),
MessageFormat: '{0}' does not contain a definition for '{1}' and no accessible extension method '{1}' accepting a first argument of type '{0}' could be found (are you missing a using directive or an assembly reference?),
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
{
ctx.Db.Player.Delete(new Player { Identity = new() });
^^^^^^
return null;
*/
Message: 'PlayerReadOnly' does not contain a definition for 'Delete' and no accessible extension method 'Delete' accepting a first argument of type 'PlayerReadOnly' could be found (are you missing a using directive or an assembly reference?),
Severity: Error,
Descriptor: {
Id: CS1061,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1061),
MessageFormat: '{0}' does not contain a definition for '{1}' and no accessible extension method '{1}' accepting a first argument of type '{0}' could be found (are you missing a using directive or an assembly reference?),
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
{
ctx.Db.Player.Insert(new Player { Identity = new() });
^^^^^^
return new Player { Identity = new() };
*/
Message: 'PlayerReadOnly' does not contain a definition for 'Insert' and no accessible extension method 'Insert' accepting a first argument of type 'PlayerReadOnly' could be found (are you missing a using directive or an assembly reference?),
Severity: Error,
Descriptor: {
Id: CS1061,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1061),
MessageFormat: '{0}' does not contain a definition for '{1}' and no accessible extension method '{1}' accepting a first argument of type '{0}' could be found (are you missing a using directive or an assembly reference?),
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
{
ctx.Db.Player.Iter();
^^^^
return null;
*/
Message: 'PlayerReadOnly' does not contain a definition for 'Iter' and no accessible extension method 'Iter' accepting a first argument of type 'PlayerReadOnly' could be found (are you missing a using directive or an assembly reference?),
Severity: Error,
Descriptor: {
Id: CS1061,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1061),
MessageFormat: '{0}' does not contain a definition for '{1}' and no accessible extension method '{1}' accepting a first argument of type '{0}' could be found (are you missing a using directive or an assembly reference?),
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
// Valid Filter, but [ClientVisibilityFilter] is disabled
[SpacetimeDB.ClientVisibilityFilter]
Expand Down Expand Up @@ -114,6 +229,29 @@ public partial struct TestDefaultFieldValues
]
}
},
{/*

var returnValue = Module.ViewDefWrongContext((SpacetimeDB.ViewContext)ctx);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
using var output = new System.IO.MemoryStream();
*/
Message: Argument 1: cannot convert from 'SpacetimeDB.ViewContext' to 'SpacetimeDB.ReducerContext',
Severity: Error,
Descriptor: {
Id: CS1503,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1503),
MessageFormat: Argument {0}: cannot convert from '{1}' to '{2}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_SECOND_FILTER);
SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THIRD_FILTER);
Expand All @@ -137,6 +275,75 @@ SpacetimeDB.Internal.Module.RegisterClientVisibilityFilter(global::Module.MY_THI
]
}
},
{/*

var returnValue = Module.ViewDefNoContext((SpacetimeDB.ViewContext)ctx);
^^^^^^^^^^^^^^^^
using var output = new System.IO.MemoryStream();
*/
Message: No overload for method 'ViewDefNoContext' takes 1 arguments,
Severity: Error,
Descriptor: {
Id: CS1501,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS1501),
MessageFormat: No overload for method '{0}' takes {1} arguments,
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*

private static readonly SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN> returnRW = new();
^^^^^

*/
Message: The type name 'BSATN' does not exist in the type 'NotSpacetimeType',
Severity: Error,
Descriptor: {
Id: CS0426,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0426),
MessageFormat: The type name '{0}' does not exist in the type '{1}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
Params: [],
ReturnType: new SpacetimeDB.BSATN.ValueOption<NotSpacetimeType, NotSpacetimeType.BSATN>().GetAlgebraicType(registrar)
^^^^^
);
*/
Message: The type name 'BSATN' does not exist in the type 'NotSpacetimeType',
Severity: Error,
Descriptor: {
Id: CS0426,
Title: ,
HelpLink: https://msdn.microsoft.com/query/roslyn.query?appId=roslyn&k=k(CS0426),
MessageFormat: The type name '{0}' does not exist in the type '{1}',
Category: Compiler,
DefaultSeverity: Error,
IsEnabledByDefault: true,
CustomTags: [
Compiler,
Telemetry,
NotConfigurable
]
}
},
{/*
{
internal static readonly TRW FieldRW = new();
Expand Down
Loading
Loading