-
Notifications
You must be signed in to change notification settings - Fork 620
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stabilize EmptySerializersModule #1921
Conversation
See also #1765 (comment) This is a legit concern that this decision is slightly out of line with our general design. We can discuss and decide whether we want to disrupt API a bit, deprecate |
But why |
then also |
e534dd7
to
856f117
Compare
It seems like the most optimal way here is to be consistent within the library itself and name it The standard library is a different beast with different sets of tradeoffs. It still carries the heavy influence of Java since its earlier versions and tries to be consistent with itself, even though as time passes, we (Kotlin libraries developers) find better ways to design and express things. E.g. we could've decided that |
@@ -80,29 +80,39 @@ class SerializationMethodInvocationOrderTest { | |||
|
|||
override fun <T : Any?> encodeSerializableValue(serializer: SerializationStrategy<T>, value: T) { | |||
when (step) { | |||
0, 3 -> { step++; serializer.serialize(this, value); return } | |||
0, 3 -> { | |||
step++; serializer.serialize(this, value); return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to make it multi-line, also split statements instead of using ;
If it's autoformatting, better to revert it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Rename signature" for some reason apply formatting all over the place
@@ -18,6 +19,9 @@ import kotlin.reflect.* | |||
* To enable runtime serializers resolution, one of the special annotations must be used on target types | |||
* ([Polymorphic] or [Contextual]), and a serial module with serializers should be used during construction of [SerialFormat]. | |||
* | |||
* Serializers module can be built with `SerializersModule {}` builder function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we need to do one or two things:
- Optimize
SerializersModule {}
so it would returnEmptySerializersModule
when appropriate - Make a diagnostic that suggest replacing
SerializersModule {}
withEmptySerializersModule()
as we have with Json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly do not see reasons to do so, this optimization doesn't carry any real value as well as the diagnostic.
Json
is a different beast as it has a non-trivial initialization cost and also prevents any format-level caching.
@qwwdfsad We already has the same problem with |
Fixes #1765