Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create RangedIndex interface used in C# codegen similar to Rust #2316

Open
kazimuth opened this issue Feb 26, 2025 · 0 comments
Open

Create RangedIndex interface used in C# codegen similar to Rust #2316

kazimuth opened this issue Feb 26, 2025 · 0 comments

Comments

@kazimuth
Copy link
Contributor

kazimuth commented Feb 26, 2025

Currently, the module-side generated data structures for indexes don't implement a single interface, despite all having the same interface. The generated code for these looks like

public sealed class nameIndex() : SpacetimeDB.Internal.IndexBase<global::SpacetimeDB.Modules.ModuleTestCs.TestE>("test_e_name_idx_btree") {
    public IEnumerable<global::SpacetimeDB.Modules.ModuleTestCs.TestE> Filter(string name) =>
        DoFilter(new SpacetimeDB.Internal.BTreeIndexBounds<string, SpacetimeDB.BSATN.String>(name));

    public ulong Delete(string name) =>
        DoDelete(new SpacetimeDB.Internal.BTreeIndexBounds<string, SpacetimeDB.BSATN.String>(name));

    public IEnumerable<global::SpacetimeDB.Modules.ModuleTestCs.TestE> Filter(Bound<string> name) =>
        DoFilter(new SpacetimeDB.Internal.BTreeIndexBounds<string, SpacetimeDB.BSATN.String>(name));

    public ulong Delete(Bound<string> name) =>
        DoDelete(new SpacetimeDB.Internal.BTreeIndexBounds<string, SpacetimeDB.BSATN.String>(name));

}

Either IndexBase should grow more methods, an interface should be added, or this sort of index should be converted to a single data structure.
This is a wart that could be fixed backwards-compatibly since it is only visible inside modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant