SpacetimeDB icon indicating copy to clipboard operation
SpacetimeDB copied to clipboard

View C# Generation Fails with Namespace

Open JasonAtClockwork opened this issue 1 month ago • 0 comments

DESCRIPTION


When building a C# server module using a namespace for the Module the return value for any defined Views will be mangled in the FFI.cs.

EXAMPLE


using SpacetimeDB;

namespace Test;
public static partial class Module
{
    [SpacetimeDB.Table]
    public partial struct Person
    {
        [SpacetimeDB.AutoInc]
        [SpacetimeDB.PrimaryKey]
        public int Id;
        public string Name;
        public int Age;
    }
    
   
    [SpacetimeDB.View(Name = "MyPerson", Public = true)]
    public static Person? MyPerson(ViewContext ctx) =>
        ctx.Db.Person.Id.Find(0);

    [SpacetimeDB.Reducer]
    public static void Add(ReducerContext ctx, string name, int age)
    {
        var person = ctx.Db.Person.Insert(new Person { Name = name, Age = age });
        Log.Info($"Inserted {person.Name} under #{person.Id}");
    }

    [SpacetimeDB.Reducer]
    public static void SayHello(ReducerContext ctx)
    {
        foreach (var person in ctx.Db.Person.Iter())
        {
            Log.Info($"Hello, {person.Name}!");
        }
        Log.Info("Hello, World!");
    }
}

TODO


  • [ ] Repair the codegen to properly parse the type for ReturnType on ViewDispatcher

JasonAtClockwork avatar Nov 13 '25 15:11 JasonAtClockwork