Thread
#arrow-meta
    Tim Abil

    Tim Abil

    4 months ago
    I'm trying to read moshi's
    @Json
    property annotation that overrides serialized property names while visiting class properties with
    DeclarationDescriptorVisitor
    from
    declarationChecker{..}
    . When
    visitPropertyDescriptor
    is invoked
    descriptor.annotations
    is always empty.
    import com.squareup.moshi.Json
    
    data class Sample(
        val a: Color,
        @Json(name="json_name") <-- not visible from declaration checker
        val b: More,
    )
    e

    ephemient

    4 months ago
    @Json
    doesn't declare applicable targets (therefore all are allowed): https://square.github.io/moshi/1.x/moshi/moshi/com.squareup.moshi/-json/index.html which means it'll be treated as
    @param:Json
    in this usage by default: https://kotlinlang.org/docs/annotations.html#annotation-use-site-targets
    Tim Abil

    Tim Abil

    4 months ago
    ahh i see, any way to get a reference to those from PropertyDescriptor?
    e

    ephemient

    4 months ago
    can you change the code to declare the annotation target explicitly instead?
    @property:Json(...) val
    Tim Abil

    Tim Abil

    4 months ago
    hmm i might not have the access to change the class definitions tho
    i guess i need to somehow be able to access @Documented string
    @raulraja thoughts?