Skip to content

Request to make StringResource/ResourceFormattedStringDesc serialization compatible #816

Open

Description

@popovych-y

I am trying to implement a custom kotlinx.serialization serializer for the ResourceFormattedStringDesc to be able to pass it as navigation argument. This can be implemented relatively easy for Android/JVM platforms. But for JS i've faced an issue that the key parameter for the StringResource is private so i can't read it in reliable way

JS target

actual class StringResource(
    private val key: String,
    val loader: RemoteJsStringLoader
)

The approach with asDynamic() works but the field name is changed during compilation to key_1 and i can't be sure it is the stable name.

private val StringResource.keyUnsafe: String get() = this.asDynamic().key_1 as String

So the request is to make the key field public for the JS target so i can read it and serialize without hacks.

Additionally would be nice to make public stringRes and args fields for the JVM target also to avoid using reflection

JVM target

actual data class ResourceFormattedStringDesc actual constructor(
    private val stringRes: StringResource,
    private val args: List<Any>
) : StringDesc

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions