Closed joelmartinez closed 10 months ago
Hey @joelmartinez,
This looking similar to https://github.com/bottlenoselabs/c2cs/issues/150.
The code that would need to change is here: https://github.com/bottlenoselabs/c2cs/blob/main/src/cs/production/C2CS.Tool/Features/WriteCodeCSharp/Domain/CodeGenerator/Handlers/MacroCodeGenerator.cs#L41.
@lithiumtoast ahh yes indeed, that does look like a) the same issue, and b) probably where that needs to change. Would this be a simple enough change?
code = $@"
{attributesString}
public static {node.Type} {name} = ({node.Type}){node.Value};
";
If so ... do you want me to open a PR with this? Do you think it's easy enough to onboard by cloning the repo and making the change? would you recommend adding some test for this somewhere?
@lithiumtoast ok, so I created a pull request with this change. I ran the unit tests and they all passed. There were a few updates I didn't include, for example some changes to the generated metadata of the generated files, e.g.
-// This code was generated by the following tool on 2023-07-23 05:51:56 GMT-04:00:
-// https://github.com/bottlenoselabs/c2cs (v2.11.1.99)
+// This code was generated by the following tool on 2023-11-05 09:24:44 GMT-05:00:
+// https://github.com/bottlenoselabs/c2cs (v15.0.0.0)
Let me know if you want me to include those in the PR as well
Hey @joelmartinez,
I see you figured it out with your PR #157.
Would you recommend adding some test for this somewhere?
When I split CAstFfi
from C2CS
, looks like I didn't build out a lot of tests for the C# side. I have the basics going for enums: https://github.com/bottlenoselabs/c2cs/blob/main/src/cs/tests/C2CS.Tests/TestCSharpCode.cs#L14.
If you are feeling up to it, you could add a test for a macro object using a theory attribute for macro objects similar to enums.
The JSON test files are automatically re-generated by flipping this boolean to true
in the constructor: https://github.com/bottlenoselabs/c2cs/blob/main/src/cs/tests/C2CS.Tests/TestCSharpCode.cs#L44. Looks like I forgot to turn it off and committed; it should be false
when merging into main
to use existing test files so testing is actually comparing against existing values.
I merged it in thanks, @joelmartinez
@joelmartinez It's up on NuGet as version 6.1.4
: https://www.nuget.org/packages/bottlenoselabs.C2CS.Tool
Amazing, thank you @lithiumtoast! Sorry, I meant to post/respond that I had started to take a look at adding the unit test, but unfortunately I was quite busy and didn't get a chance to really dig in. Appreciate your help in this 🙏🏼
@joelmartinez I did it as part of https://github.com/bottlenoselabs/c2cs/pull/158. There was a couple things that needed fixing to make adding more unit tests easier anyways.
Hi ... I'm working on generating bindings with c2cs, and am getting the following error during the generate command:
That points to this line:
So the
128
is just missing an explicit cast to_lv_buttonmatrix_ctrl_t
And if it helps, here's the corresponding enum definition in the ast file:
Any hints or ideas as to what might be going on and how to mitigate would be greatly appreciated!