is there any way to configure serialization global...
# serialization
n
is there any way to configure serialization globally to not use fully qualified classnames for polymorphism ? and instead just use the simple class name ?
a
You can put a
@SerialName
annotation on each class you need to have this behavior, and set the value to the class name, it's not automatic but it's at least simple to setup
n
that is what we are doing
o
Seems there is no way to do it currently. Relevant code in the serialization plugin:
Copy code
fun IrClass.serialName(): String {
    return annotations.serialNameValue ?: fqNameWhenAvailable?.asString() ?: error("${this.render()} does not have fqName")
}
AFAIK, even writing another compiler plugin which adds
@SerialName
annotations will fail to achieve the intended result, as there is no way to configure the order of plugin invocations in the compiler.
Maybe this could work if annotations are added in frontend IR and evaluated by the serialization plugin's backend only. Ideally, there would be a configurable transformation function which could either strip qualifiers, shorten names, map names to stable IDs, or whatever might be useful. Why not file a feature request with your use case?