Hey I was wondering if it was possible to put prop...
# getting-started
Hey I was wondering if it was possible to put properties on a class via annotation? Example being
Copy code
annotation class Example(val a: String)

class Foo() 
// to
class Foo(val: a = "t")
Yes it's possible but with an annotation processor, for example KSP
Ah, I’ve been looking into this for a bit and I’ve seen KSP but it’s something I didn’t really want to learn how to implement yet but if it’s the only way I’ll just learn it. Thank you!
allows transformations?
I don't think so, you probably will need your own compiler plugin
🤔 I’m not home at the moment but when I was looking into it I believe I saw you could write into classes and stuff so you could probably add properties onto it
Not too sure though.
Javier is correct. KSP can only add code, but not modify it. See https://kotlinlang.org/docs/ksp-overview.html#overview : 1. Processors read and analyze source programs and resources. 2. Processors generate code or other forms of output. 3. The Kotlin compiler compiles the source programs together with the generated code. Unlike a full-fledged compiler plugin, processors cannot modify the code. A compiler plugin that changes language semantics can sometimes be very confusing. KSP avoids that by treating the source programs as read-only.