-
Notifications
You must be signed in to change notification settings - Fork 34
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
Non-conventional C# multi-dimensional arrays generated #346
Comments
Thanks for opening this issue. Bebop only supports jagged arrays and has no concept for multi-dimensional arrays. While C# does support multi-dimensional arrays, languages Bebop also supports such as Rust and Dart do not. So we only generate data structures that every language can support. |
Thanks for replying. If I understand right, the bebop generators are language specific, so this can be customized? A simple recursive function that stops on a non array can yield the array dimensions. Could this be implemented in the lines mentioned above? bebop/Core/Generators/CSharp/CSharpGenerator.cs Lines 1312 to 1348 in 2108a61
Here's an example of how this function could look like: private int ArrayDimension(in TypeBase type)
{
return type switch
{
ArrayType at => 1 + ArrayDimension(at.MemberType),
_ => 0
};
} |
@andrewmd5 We really could use this. Crippling bebop wouldn't be ideal, as both languages that we're using support multi-dimensional arrays. Perhaps a warning that this is only supported on some languages in the readme or something would be best. |
Describe the bug
In C#, a multi-dimensional array is declared with commas in-between the square brackets (
[,]
), and not conventionally with square brackets stacked ([][]
).bebop/Core/Generators/CSharp/CSharpGenerator.cs
Lines 1341 to 1342 in 2108a61
This line should not append the type recursively to be
(recursive call)[]
, but instead read out the dimension of the array, and write commas by formula by pseudo-code"[" + ",".repeat(dimension - 1) + "]"
.A clear and concise description of what the bug is.
To Reproduce
Expected behavior
The generated C# code should have multi-dimensional arrays with the respective commas
[,]
and[,,]
Screenshots / Snippets
Bebop info:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: