Skip to content
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

Add inline reified version of encodeToString as a Json member to to streamline experience for newcomers. #2853

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

sandwwraith
Copy link
Member

decodeFromString was already there for @FormatLanguage reasons.

Fixes #2850

…treamline experience for newcomers.

decodeFromString was already there for @FormatLanguage reasons.

Fixes #2850
@sandwwraith sandwwraith requested a review from shanshin November 8, 2024 17:15
@hfhbd
Copy link
Contributor

hfhbd commented Nov 12, 2024

This still means every 3rd party serialization format author needs to copy these inline functions too, isn't it?

@sandwwraith
Copy link
Member Author

@hfhbd No, why? Original inline extension functions are not going anywhere.

@hfhbd
Copy link
Contributor

hfhbd commented Nov 12, 2024

Yes that's true but the user still needs to import the extension functions from kotlinx.serialization while using FooFormat in com.foo because it is an extension function and not part of the SerialFormat as a member (not requiring an import).

@sandwwraith
Copy link
Member Author

Yes, just as any other extension function? I do not see a problem here

@hfhbd
Copy link
Contributor

hfhbd commented Nov 12, 2024

It is not a problem for the json format, but a general feedback I got from users of my format that they forgot to import the extension method so instead fixing it in Json only (by copying the methods), a general solution to migrate the extension functions to members would improve all 3rd party formats too. Then no other format authors needs to copy the extension functions to have them as a member.

@sandwwraith
Copy link
Member Author

a general solution to migrate the extension functions to members would improve all 3rd party formats, too

That is true, but unfortunately, interfaces can't contain final inline functions.

So if your users complain about the same problem a lot, the only workaround here is to copy these inline functions, as in this PR

@sandwwraith sandwwraith merged commit d266e05 into dev Nov 14, 2024
4 checks passed
@sandwwraith sandwwraith deleted the json-extensions-as-members branch November 14, 2024 16:51
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.

3 participants