-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add ToString methods #437
Add ToString methods #437
Conversation
Latest macos runner had missing dependencies for testing, macos-12 still has these.
Thank you for the contribution here. The change looks reasonable. However, since FlatSharp generates all classes as Partial, I'd like to find a way to make this an optional (opt-out?) behavior. It's conceivable that there are people who have defined their own partial classes with their own ToString implementations, and I'd prefer not to break them if I can avoid it. |
Maybe we could go about that with an opt-in or opt-out flag in the command-line? Unless there is another avenue for a more suitable solution. |
After a bit of deliberation, I'd like to make this opt-in for FlatSharp 7.X, with a switch to opt-in when FlatSharp 8 is released (no ETA on that, but I have promised semantic versioning for FlatSharp, so I try very hard to avoid breaking changes in non-major versions). I can think of three realistic options:
=================== The other thing I wonder is the benefit of generating other common methods, such as enum MethodGenerationOptions
{
None = 0,
ToString = 1,
Equality = 2, // !=, ==, .Equals(), .GetHashCode. Maybe split out != and == into a different EqualityOperators category
All = 3,
} The usage could be: For the record, I'm not asking you to add all of the other helper methods. However, I'm interested in making this one part of a broader setup. Do you have any feedback on this approach? =================== Wrapping up, I'm happy to accept a PR contribution here with any of options 1, 2, or 3. Please do make the syntax reasonably generic such as |
I think option 1 will be good to begin with. Ultimately, if FlatSharp were turned into a source generator, it could detect if ToString is already defined by the user in a partial class before generating its own. Regarding the enum, I think that's good if there's nothing added in the future, but if there is then it might get complicated to generate a subset of the methods. I feel like it will be simpler to just have one flag/attribute per group of methods. E.g., I can image wanting to add We actually have some of the equality code in trumully#7 For our code base, we treat all |
I've added a command-line flag If you don't like the test done in this way, there are a few other options:
|
Hi there -- just a quick note that I haven't forgotten about you. I've been ill for the past week (perks of having a toddler) and am not in the right headspace to give this PR the attention it deserves. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the ridiculously late review. Approved! Please let me know if you need help resolving merge conflicts.
Thanks again for making these changes. Sorry again for the long delay. There is no excuse for me. FlatSharp 7.8 will publish soon with this as the last PR. |
This adds tests for the feature originally authored in #417. Let me know if you want any of these tweaked.
Also made some tweaks to the runner versions as macos was missing dependencies that your CI needed.