-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
Generate overwritten GetHashCode method for C# models #467
Comments
Can I take this |
@octonawish-akcodes there are no assignments or anything in that way, so it's all about just doing it 😊 Go for it 👍 |
Working on it @jonaslagoni along with #466 |
Hey @jonaslagoni.
or is this a default behaviour ? (kinda new to c#) |
We can include both the May be i'm lacking some knowledge of C# here meaning to what these flags actually are doing to the generated models. |
By default (for this preset), there is no difference between not setting the options and setting them to true, both are added by default. So from the CLI's perspective, you can default both to For autoImplement, its actually a bit obscure and the example does not really show it correct... Because the preset, is just the default preset, with custom options (i.e. it's actually rendered twice, we just don't know it).
Yep, you can have as many as you wish, you can read more about them here: https://github.com/asyncapi/modelina/blob/master/docs/presets.md So as long as the CSHARP_DEFAULT_PRESET is first, you can stack them similar to something like this (just pseudo code):
|
@jonaslagoni thanks. Cleared my mind. Do you think one PR would be sufficient to fix both the issues in that case? |
Definitely 👍 |
🎉 This issue has been resolved in version 0.42.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Reason/Context
In Modelina for C#, you can make it generate the models with the GetHashCode method overwritten, this should be possible through the CLI.
To do this I suggest we add a flag called
csharpHashcode
as a boolean. If true the generator should include the following options:Which should be added here:
cli/src/commands/generate/models.ts
Line 137 in 438de07
These will be the generated results: https://github.com/asyncapi/modelina/blob/master/examples/csharp-generate-json-serializer/__snapshots__/index.spec.ts.snap
Remember to also add a test here:
cli/test/commands/generate/models.test.ts
Line 95 in 438de07
Related documentation: https://github.com/asyncapi/modelina/blob/master/docs/languages/Csharp.md#generate-models-with-equals-and-gethashcode-methods
Feel free to reach out if you have any questions or get stuck!
Related issue #466
The text was updated successfully, but these errors were encountered: