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

c# client generate #1707

Merged
merged 7 commits into from
Oct 4, 2024
Merged

c# client generate #1707

merged 7 commits into from
Oct 4, 2024

Conversation

lcodes
Copy link
Contributor

@lcodes lcodes commented Sep 12, 2024

Rust side generating module bindings for clockworklabs/com.clockworklabs.spacetimedbsdk#131

@lcodes lcodes added the abi-break A PR that makes an ABI breaking change label Sep 12, 2024
@lcodes lcodes requested a review from RReverser September 16, 2024 17:11
@RReverser
Copy link
Contributor

@lcodes lcodes requested a review from RReverser 18 minutes ago

FWIW I'm going to review this one in more detail after the runtime counterpart.

@RReverser RReverser mentioned this pull request Sep 25, 2024
@lcodes lcodes force-pushed the jeremie/cs-sdk branch 3 times, most recently from a43929e to b355fe5 Compare October 1, 2024 01:20
@cloutiertyler cloutiertyler mentioned this pull request Oct 1, 2024
2 tasks
@lcodes lcodes force-pushed the jeremie/cs-sdk branch 2 times, most recently from 321d801 to c761d5a Compare October 2, 2024 17:00
@RReverser
Copy link
Contributor

@lcodes AddPlayerArgsStruct and such are different from naming in Phoebe's and your own proposal (https://github.com/clockworklabs/SpacetimeDBPrivate/pull/949).

I always wanted to remove that ArgsStruct suffix too, but was punting off as it would be a breaking change, but now we have a perfect excuse for breaking changes - it's in the spec!

@RReverser
Copy link
Contributor

RReverser commented Oct 2, 2024

In a scenario like this:

internal static partial class Outer
{
    [SpacetimeDB.Table]
    public partial struct InnerTable
    {
        public string Name;
    }
}

we will currently generate an ITableView implementation with public visibility, which will result in

Assert.Empty() Failure: Collection was not empty
Collection: [SpacetimeDB.Codegen\SpacetimeDB.Codegen.Module\FFI.cs(142,50): error CS0050: Inconsistent accessibility: return type 'IEnumerable<Outer.InnerTable>' is less accessible than method 'InnerTable.Iter()', SpacetimeDB.Codegen\SpacetimeDB.Codegen.Module\FFI.cs(143,37): error CS0050: Inconsistent accessibility: return type 'Outer.InnerTable' is less accessible than method 'InnerTable.Insert(Outer.InnerTable)', SpacetimeDB.Codegen\SpacetimeDB.Codegen.Module\FFI.cs(143,37): error CS0051: Inconsistent accessibility: parameter type 'Outer.InnerTable' is less accessible than method 'InnerTable.Insert(Outer.InnerTable)', SpacetimeDB.Codegen\SpacetimeDB.Codegen.Module\FFI.cs(144,17): error CS0051: Inconsistent accessibility: parameter type 'Outer.InnerTable' is less accessible than method 'InnerTable.Delete(Outer.InnerTable)']
Stack Trace:
at SpacetimeDB.Codegen.Tests.GeneratorSnapshotTests.TypeAndModuleGeneratorsOnServer() in D:\SpacetimeDB\crates\bindings-csharp\Codegen.Tests\Tests.cs:line 152
--- End of stack trace from previous location ---

We should instead generate it as an internal. I think in the visibility loop you need to take the minimum of any visibility you've seen while traversing up.

@RReverser
Copy link
Contributor

Also mentioned this before, but right now Module.verified.txt results in couple of An internal error occurred during codegen: ... due to usage of exceptions for columns and visibility checks.

Could you please convert those to 2 new diagnostics with location context attached?

@RReverser RReverser mentioned this pull request Oct 2, 2024
2 tasks
Copy link
Collaborator

@jdetter jdetter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not done a code review on this but I've tested it against circle game and it works.

@bfops bfops added this pull request to the merge queue Oct 4, 2024
Merged via the queue into master with commit 02b70d5 Oct 4, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abi-break A PR that makes an ABI breaking change release-0.12
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants