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

BUG: C# codegen erroneously generates two types instead of one type for two tables that share the same type #2106

Open
cloutiertyler opened this issue Jan 13, 2025 · 2 comments · May be fixed by #2184
Assignees

Comments

@cloutiertyler
Copy link
Contributor

cloutiertyler commented Jan 13, 2025

To reproduce, create a module with the following two table definitions.

#[spacetimedb::table(name = player, public)]
#[spacetimedb::table(name = logged_out_player)]
#[derive(Debug, Clone)]
pub struct Player {
    #[primary_key]
    identity: Identity,
    #[unique]
    #[auto_inc]
    player_id: u32,
    name: String,
}

Run spacetime generate --lang csharp

The command will generate Player.cs and LoggedOutPlayer.cs with identical content (shown below), creating a duplicate type definition of Player.

// THIS FILE IS AUTOMATICALLY GENERATED BY SPACETIMEDB. EDITS TO THIS FILE
// WILL NOT BE SAVED. MODIFY TABLES IN RUST INSTEAD.
// <auto-generated />

#nullable enable

using System;
using SpacetimeDB;
using System.Collections.Generic;
using System.Runtime.Serialization;

namespace SpacetimeDB.Types
{
	[SpacetimeDB.Type]
	[DataContract]
	public partial class Player : IDatabaseRow
	{
		[DataMember(Name = "identity")]
		public SpacetimeDB.Identity Identity;
		[DataMember(Name = "player_id")]
		public uint PlayerId;
		[DataMember(Name = "name")]
		public string Name;

		public Player(
			SpacetimeDB.Identity Identity,
			uint PlayerId,
			string Name
		)
		{
			this.Identity = Identity;
			this.PlayerId = PlayerId;
			this.Name = Name;
		}

		public Player()
		{
			this.Identity = new();
			this.Name = "";
		}

	}
}
@gefjon
Copy link
Contributor

gefjon commented Jan 24, 2025

Per @RReverser , related by @cloutiertyler , this will be fixed along with some other bugs (unspecified) by a PR which reworks C# codegen to use the V9 module def.

@RReverser RReverser linked a pull request Jan 28, 2025 that will close this issue
2 tasks
@gefjon
Copy link
Contributor

gefjon commented Jan 29, 2025

PR is up; needs testing.

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

Successfully merging a pull request may close this issue.

3 participants