-
Notifications
You must be signed in to change notification settings - Fork 664
Open
Description
As reported by a Spacetime community user Arc, a bug exists in the C# View code where they were getting an error in 1.11.1 on the code:
[View(Name = nameof(MyAccount), Public = true)]
public static Account? MyAccount(ViewContext ctx)
{
return ctx.Db.Account.Identity.Find(ctx.Sender) as Account;
}Where Account? is a class.
The validator for [SpacetimeDB.View] return types was only accepting:
SpacetimeDB.BSATN.List<...>(like “Vec”)SpacetimeDB.BSATN.ValueOption<...>(nullable value types /T?whereT : struct)
But nullable reference types like Account? (where Account : class) are represented by BSATN as:
SpacetimeDB.BSATN.RefOption<...>
So the analyzer/codegen incorrectly rejected Account? with:
View 'MyAccount' must return Vec or Option. (STDB0024)
The existing regression test passed because the row type there is a struct (so Player? mapped to ValueOption) or otherwise didn’t hit the RefOption path.
Metadata
Metadata
Assignees
Labels
No labels