C# and Rust modules have different server-side reducer names
Noticed this while playing with Blackholio.
Swapping between the C# and Rust versions of the modules, the generated code is ALMOST identical. In the C# client code, the user can always call reducers like .EnterGame() and have it work.
The difference is that, if the C# version of the module is used, under the hood, .EnterGame() sends a message containing the string "EnterGame". On the other hand, if the Rust version of the module is used, under the hood, .EnterGame() send a message containing the string "enter_game". This means that the user needs to regenerate client code when swapping between the modules, despite there not being any user-facing API changes.
If we want to fix this, we could canonicalize reducer names in a module to either a snake_case or a CamelCase convention.
Swapping between the C# and Rust versions of the modules, the generated code is ALMOST identical. In the C# client code, the user can always call reducers like
.EnterGame()and have it work.
FWIW you could just rename C# methods to match Rust ones - that's what we do for ModuleDef equivalence comparisons between C#/Rust modules in tests.
In the future we may choose to add a feature like this that allows users to choose the server-side reducer name, e.g.:
#[reducer(name = EnterGame)]
fn enter_game()
@gefjon do you have thoughts about this?
Nope!
if we run out of time we'll move this to P2, but we think we should do this.
@cloutiertyler asked to assign this to @Centril (we think @coolreader18 could probably do this quickly as a backup)
~~We are going to do canonicalize to snake_case and we're going to try to do this if we have time.~~ ~~We are not going to canonicalize this. In the future we are going to allow you to specify a name field for reducers~~
JK we are not going to canonicalize this. We are going to have all module libraries submit snake_case names by default as the name.
In the future, you will be able to set the name that the library provides to be whatever you want:
#[reducer(name = "EnterGame")]
fn enter_game()
#[Reducer(name = "EnterGame")]
void EnterGame()
We think this #[reducer(...)] syntax already exists, at least in Rust. We should confirm in C#.
WONTFIX. Down the line, we may make it so that spacetime call and friends do automatic case-conversion behind the scenes, "do-what-i-mean" style, so long as there's no ambiguity caused by name collisions. We will also do something to make it so that modules by default submit snake-case names. What specifically we will do is yet to be determined.
We'll address this in Blackholio by not checking in the bindings, that way there's a mandatory user step of "generate the bindings"