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

Add enum value support #28

Merged
merged 4 commits into from
Feb 26, 2019
Merged

Add enum value support #28

merged 4 commits into from
Feb 26, 2019

Conversation

tagantroy
Copy link
Contributor

This MR adds support for enum values.
DecodedEnum contains a string value (same as DecodedString)

@hongbinh
Copy link
Contributor

Thanks for the PR, we will review within next two weeks.

Copy link
Contributor

@hongbinh hongbinh left a 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 {
Copy link
Contributor

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!

Copy link
Contributor

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

Copy link
Contributor Author

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
Copy link
Contributor

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

Copy link
Contributor Author

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)
Copy link
Contributor

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()

Copy link
Contributor

@kkoser kkoser left a 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 {
Copy link
Contributor

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

@tagantroy
Copy link
Contributor Author

@kkoser @hongbinh I fixed comments, can you review and merge?

Copy link
Contributor

@hongbinh hongbinh left a 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!

@hongbinh hongbinh merged commit 8de561b into linkedin:master Feb 26, 2019
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.

3 participants