Skip to content

Extend custom serializers support in decoding#318

Merged
BOOMeranGG merged 4 commits into
mainfrom
extend-custom-serializers-support-in-decoder
May 17, 2025
Merged

Extend custom serializers support in decoding#318
BOOMeranGG merged 4 commits into
mainfrom
extend-custom-serializers-support-in-decoder

Conversation

@BOOMeranGG

@BOOMeranGG BOOMeranGG commented May 1, 2025

Copy link
Copy Markdown
Collaborator

@BOOMeranGG
BOOMeranGG requested a review from orchestr7 May 1, 2025 22:19
@BOOMeranGG
BOOMeranGG force-pushed the extend-custom-serializers-support-in-decoder branch from bdeccad to 1e7d6c8 Compare May 1, 2025 22:24
@BOOMeranGG
BOOMeranGG force-pushed the extend-custom-serializers-support-in-decoder branch from 1e7d6c8 to 0670267 Compare May 1, 2025 22:27
* @param config - decoding configuration for parsing and serialization
* @return decoded (deserialized) object of type T
*/
public fun <T> decode(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, don't get the idea - why this should be added to particular desrializers like ArrayDecoder?

@BOOMeranGG BOOMeranGG May 14, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did the same as I did for map: #291 (comment)
Now in Toml.kt we have:

    private fun <T> decode(deserializer: DeserializationStrategy<T>, parsedToml: TomlFile): T =
        when (deserializer.descriptor.kind) {
            StructureKind.LIST -> TomlArrayDecoder.decode(deserializer, parsedToml.getFirstChild() as TomlKeyValueArray, inputConfig)
            StructureKind.MAP -> TomlMapDecoder.decode(deserializer, parsedToml, inputConfig)
            else -> TomlMainDecoder.decode(deserializer, parsedToml, inputConfig)
        }

It's used only with delegating serializer (see delegatingSerializer test)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it!

import kotlin.test.Test
import kotlin.test.assertEquals

class CustomSerializerTest {

@orchestr7 orchestr7 May 10, 2025

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember, I had CustomSerializerTest with some @ignored tests

kotlin/com/akuleshov7/ktoml/decoders/CustomSerializerTest.kt

May be unify and remove @Ignored in some of tests? 🙏🏾

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the same class, I just moved it to /custom/ directory

@orchestr7

Copy link
Copy Markdown
Owner

Generally LGTM, also conflicts might be resolved

@orchestr7

Copy link
Copy Markdown
Owner

I believe that once we merge it, it'll be time to make the release. @BOOMeranGG, this release will be yours—and only yours—and it will be officially named 'Evgeny Bykov's Release'! :)

I'll also write up a post on Reddit. It’s finally time to push through that 500-star milestone )

# Conflicts:
#	ktoml-core/src/commonTest/kotlin/com/akuleshov7/ktoml/decoders/structures/MapDecoderTest.kt
@BOOMeranGG

BOOMeranGG commented May 14, 2025

Copy link
Copy Markdown
Collaborator Author

I believe that once we merge it, it'll be time to make the release. @BOOMeranGG, this release will be yours—and only yours—and it will be officially named 'Evgeny Bykov's Release'! :)

I'll also write up a post on Reddit. It’s finally time to push through that 500-star milestone )

Haha, thank you! But don't forget other contributors, all my PRs were based on their development :)

@BOOMeranGG
BOOMeranGG merged commit 11609ed into main May 17, 2025
@BOOMeranGG
BOOMeranGG deleted the extend-custom-serializers-support-in-decoder branch May 17, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add the support for custom serialization

2 participants