Skip to content

C# bug: STDB0024 Error when a View returns a RefOption result #3962

@rekhoff

Description

@rekhoff

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? where T : 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
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions