Skip to content

View C# Generation Fails with Namespace #3658

@JasonAtClockwork

Description

@JasonAtClockwork

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

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions