-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Remove SnakeYAML for manual YAML Parser #3191
Remove SnakeYAML for manual YAML Parser #3191
Conversation
Some initial thoughts:
What is the main driving factor for this outside of what I know?
|
I dont find clear method for reading versioned data in the yaml serialization library. I realized clear straightforward method for loading data from yaml. I think simple realization we can easily refactor in the future. |
I think enum/static variable add redundant complexity. |
In my head I am thinking just a file that exports static values. It seems like it would help have a consistent location for property names. Is that the reason that it adds complexity? Or that loops/etc that were previously just simple "strings" become like Foo.String? |
Internally this will be string anyway - additional lines. |
This solution can solve #3145? |
Yes I believe so. I'm just nervous it adds managing YAML logic into Apktool's codebase, which was previously something I didn't have to worry myself with. Some of these files that managing the spec of parsing/writing YAML looks like something that can easily expand for edge cases. Unless if we stay strict to scalars - then the spec and associated logic is small. |
YamlWriter very simple. Need add some test for writer - reader and clean refs to snakeyaml. Snakeyaml is common purposes library based on reflection and the need to support the entire yaml standard hence the complexity. |
Okay, let me get out a hotfix this weekend and then focus this. If we go forward with this, I want to make sure its slated for the next "feature" release of like v2.9.0 so it has a few months to stabilize and be cleaned up w/ removal of SnakeYAML |
|
cb3e1f0
to
3644a26
Compare
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.
What I can't figure out is I pulled this locally - ran build and it failed w/
brut.androlib.apk.ApkInfoReaderTest > testFirstIncorrectIndent FAILED
java.lang.AssertionError: Values should be different. Actual: 2.8.1
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.failEquals(Assert.java:187)
at org.junit.Assert.assertNotEquals(Assert.java:163)
at org.junit.Assert.assertNotEquals(Assert.java:177)
at brut.androlib.apk.ApkInfoReaderTest.testFirstIncorrectIndent(ApkInfoReaderTest.java:64)
So I rebased this and waiting to see output.
brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlReader.java
Outdated
Show resolved
Hide resolved
brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlWriter.java
Outdated
Show resolved
Hide resolved
brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlWriter.java
Outdated
Show resolved
Hide resolved
c183d03
to
2e08282
Compare
Unused methods removed and rebased |
Odd. I still cannot build this locally without the indent test failures. Yet things pass on CI. |
Check last version. I think you tested version have version 2.8.1. My copy have 2.8.1-SNAPSHOT-... |
9fb5017
to
6912065
Compare
rebased |
My local tests pass now w/ latest change. Still trying to debug/follow the actual parser a bit more so I can make sure I understand it. One personal thing that I wish we did is less shorthand if statements. I'd much rather have: public boolean nextLine() {
if (isEnd()) {
return false;
}
while (true) {
mCurrent++;
if (isCommentOrEmpty()) {
continue;
}
return !isEnd();
}
} vs public boolean nextLine() {
if (isEnd())
return false;
while (true) {
mCurrent++;
// skip comments
if (isCommentOrEmpty())
continue;
return !isEnd();
}
} I don't think there is any need to make it as compact as possible. Its how the original AXML Parser was written and overtime as we had to add patches, etc. It just made such large diffs as we introduced curly braces. |
6912065
to
aac062c
Compare
Comment removed and rebased. |
curly braces corrected in all places |
1091cb3
to
7b09b5e
Compare
Add test for serialization hieroglyphs in the doNotCompress field |
Okay thanks. Let me do one more detailed pass through on this since its quite major. |
a28a525
to
81825cc
Compare
…erface YamlReader and add ApkInfoSerializationTest read -> write -> read test
81825cc
to
859f5e3
Compare
Okay I hammered this and can't find anything else wrong. I'll merge tomorrow morning and follow up with a commit of some minor cs changes. then I am digging into some code style automation so I never have to worry about formatting again. |
Heads up. I'm not completely sure (haven't check the code from this PR), but it seems that the new YAML writer properly outputs numeric values as numbers (in contrary to the previous implementation where numbers are casted to strings for some reason). It's not a big deal, but some dirty regex-related hacks (as in my project 😄) can break. |
Serialize to Yaml without using any library.
Its first version without cleaning refs to snakeyaml.