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

Support ScalaSerialDescriptor composite case classes #99

Merged
merged 2 commits into from
May 24, 2023

Conversation

necosta
Copy link
Contributor

@necosta necosta commented May 24, 2023

We can now serialise case classes containing case classes members. 🎉 (see unit-tests)

Notes:

  • I decided with implementing all the "givens" in a new object which needs to be imported wherever we call the serializer. Alternatively, we could have them all in ScalaSerialDescriptor object, open to suggestions.
  • I'm not sure why some derived methods had the override keyword and some not, I set all with override.

Ready for review.

@necosta necosta requested a review from Yawolf May 24, 2023 07:19
Copy link
Contributor

@raulraja raulraja left a comment

Choose a reason for hiding this comment

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

Thanks @necosta , looks great!, Left a comment around the use of strings for the match, hoping we can change that if it makes sense.

case _: (h *: t) => summonInline[ClassTag[h]] :: getElemTypes[t]
case _: (h *: t) =>
summonInline[ClassTag[h]].runtimeClass.toString match {
case s if s.toLowerCase.contains("boolean") => KotlinXSerializers.boolean.getDescriptor :: getElemTypes[t]
Copy link
Contributor

Choose a reason for hiding this comment

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

For all these cases, what happens if a type is called something like MyCustomBoolean? I think it's going to use the KotlinXSerializers.boolean.getDescriptor, which is not the right serializer. We should be matching against precise class names and not String contents.

case klass if s == summonInline[ClassTag[Boolean]].runtimeClass =>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a very good point. Will get it fixed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@franciscodr franciscodr left a comment

Choose a reason for hiding this comment

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

Beyond Raul's comment, this pull request is a great improvement. Thanks, @necosta!

Copy link
Contributor

@Yawolf Yawolf left a comment

Choose a reason for hiding this comment

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

Amazing PR! Thanks @necosta

@necosta necosta merged commit db95ac4 into main May 24, 2023
@necosta necosta deleted the feature/composite_scalaSerialDescriptor_support branch May 24, 2023 08:30
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.

4 participants