* Update to Kotlin 1.4.0
* Remove moshi-kotlin rules in favor of Kotlin's
* Ignore tests for now
* Update to OptIn
* Update test for kotlin 1.4 behavior
* Expose getStrings() option on JsonReader.Options
Resolves#1173
* Fix clone
Co-authored-by: Jake Wharton <github@jakewharton.com>
* Add mutation check
* Use set and make it unmodifiable
* Back to list
* strings()
* No clone()
Co-authored-by: Jake Wharton <github@jakewharton.com>
This makes application build with Moshi to keep unwanted Kotlin Metadata that have a huge impact on APK size.
After discussion with R8 team, there's currently no solution to avoid this other than using the trick in this PR.
Fixes https://github.com/square/moshi/issues/1115
A new user of Moshi might try to make a class like
data class Response (
val users: ArrayList<User>
)
Then when trying to create a JsonAdapter for it, they get an unhelpful error
message like
Platform class java.util.ArrayList in java.util.ArrayList<java.lang.String>
requires explicit JsonAdapter to be registered
which doesn't explain what they should do to fix the problem. In fact what it
hints towards is that the user should implement a JsonAdapter for ArrayList,
when really they just need to change the type to List!
Now the error looks like
No JsonAdapter for java.util.ArrayList<java.lang.String>, you should use
List instead of ArrayList (Moshi only supports the collection interfaces
by default).
* Fix reflection names in generated proguard files
Proguard wants to speak reflection names
* Opportunistic clean up proguard tests
This ensures we fail the test if there are any unexpected ones
* Extract target constructor signature into TargetConstructor.kt
We'll need this to know what the runtime types are for proguard rules
* Add ProguardConfig
* Wire in proguard config
* Write proguard configs out with adapters
* Add full tests
* Now remove the rules!
* Ignore on inline classes for now
* Pass adapter constructor params correctly
* Improve the way Json.name is fetched for codegen
* Remove the comment for jsonName
* Add a test for json names with quotation marks
* Fix the broken tests
* Add LocalVariableName to common suppressions
NameAllocator will add underscores to names, which kotlin doesn't like for stylistic reasons
* Simplify structure a bit
Keeping track of template counts is error prone and would have failed only at runtime
* Update to Kotlin compile testing 1.2.4
This allows us to un-toe-hold a test from before
* Fix trailing newline
* Add class-based alternative
* Use updated test API
* Update to 1.2.5
* Update to Kotlin 1.3.60
Reported by a Googler - We currently gate the lookup of the class on the presence of `Metadata`. However, `Metadata` might be justifiably stripped by Proguard/R8, even though `DefaultConstructorMarker` might still be present. This means Moshi's defaults invocation is likely broken on (at least) R8 builds without this.
Workaround until next release is to keep Metadata annotations