-
Notifications
You must be signed in to change notification settings - Fork 30
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 enum value support #28
Conversation
Thanks for the PR, we will review within next two weeks. |
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.
Thanks for adding enum value support!
companion object { | ||
fun readStringInPosition(dexFile: DexFile, position: Int): String { |
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.
Thanks for extracting common code into this new function!
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.
NP: this should probably be a private function, since its only used internally for parsing
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.
Fixed
} | ||
is EncodedValue.EncodedBoolean -> return DecodedBoolean(encodedValue.value) | ||
is EncodedValue.EncodedNull -> return DecodedNull | ||
|
||
is EncodedValue.EncodedEnum -> { | ||
val position = dexFile.stringIds[dexFile.fieldIds[encodedValue.value].nameIdx].stringDataOff |
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.
nitpick: I'd suggest to have a val nameIdx = dexFile.fieldIds[encodedValue.value].nameIdx
to make it easier to read and debug if needed
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.
Fixed
public void basicJUnit4() { | ||
assertTrue(true); | ||
} | ||
|
||
@Test | ||
@TestValueAnnotation(floatValue = 0.25f, doubleValue = 0.5, byteValue = 0x0f, charValue = '?', shortValue = 3) | ||
@TestValueAnnotation(floatValue = 0.25f, doubleValue = 0.5, byteValue = 0x0f, charValue = '?', shortValue = 3, enumValue = TestEnum.FAIL) |
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.
nitpick: I'd keep current pattern that one type only shows up once, either in basicJUnit4() or basicJUnit4Second()
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.
Would be awesome to also expose the enum type information in the DecodedEnum class, since it can't always be easily inferred and people may want to access it. It can be added separately from this though since it would just be a new field in DecodedEnum class.
Thanks for coming back to implement this, I really appreciate it!
companion object { | ||
fun readStringInPosition(dexFile: DexFile, position: Int): String { |
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.
NP: this should probably be a private function, since its only used internally for parsing
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.
Thanks for addressing the comments!
This MR adds support for enum values.
DecodedEnum contains a string value (same as DecodedString)