Skip to content
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

#47 Fixed enum assignment by index #48

Closed
wants to merge 2 commits into from

Conversation

Brainy0207
Copy link

It seems like dbc files reference the enum value by index. Changed the parser logic to pass the quoted strings to handle both cases correctly and added an additional test.

Fixes #47

Jan Oltmann added 2 commits September 25, 2023 16:01
Changed the parser logic to pass the quoted strings to handle both cases correctly.
@EFeru
Copy link
Owner

EFeru commented Sep 25, 2023

Thank you for your contribution @Brainy0207 I will do a quick review and merge soon.

@Adhara3
Copy link
Collaborator

Adhara3 commented Sep 26, 2023

Hi @Brainy0207,

thanks for the contribution and for spotting the issue.
However I think there is room for improvement, your proposed solution is breaking the responsibility chain, IMHO.
The parsing related logic (i.e. syntax related stuff or string manipulation) should stay in the (line) parser and should not leak deeper into the builder or even further into the property value and/or definition.
Moreover, analysing code we realised that we are a bit loose on other properties, e.g. we are accepting for an int property a value of "3" which should not happen, that is a string not an int.

We are then reworking a bit and refactoring also adding to the IParseFailureObserver the methods to notify the user among others:

  • a property value cannot be handled (e.g. int property receiving a string, a string property receiving an int, etc...)
  • a provided enum value is not part of the enum values listed as valid
  • a provided enum index is out of bounds (e.g. enum definition has 4 values, you provide index 5 as value)

Thanks again for your contribution, it was a very helpful hint to improve code and parsing
Feel free to review and comment our PR as soon as we push it.

A

@Brainy0207
Copy link
Author

No problem, I will have look at your PR then. My solution was just the minimal approach, to get stuff working as intended and I knew there was room for improvement, like proper argument or out of bound checks.

@Adhara3
Copy link
Collaborator

Adhara3 commented Sep 27, 2023

@Whitehouse112 merged his refactoring, please @Brainy0207 take a look and let us know if you like it

Thanks
A

@Brainy0207
Copy link
Author

Looks great. Thanks for the quick work. Now I can ditch my local fork and use the official package again.

@Brainy0207 Brainy0207 closed this Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EnumCustomProperty value is defined as integer index in dbc file
3 participants