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

Extract smithy.rust#serde trait to a new smithy-shapes Gradle subproject #3897

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

david-perez
Copy link
Contributor

@david-perez david-perez commented Oct 30, 2024

This creates a new smithy-shapes Gradle project, meant to host Smithy shapes
vended by smithy-rs. The project must host only their definitions, not any
code-generating implementations. This way model authors can depend on these
shapes and consumers don't have to care about smithy-rs and its dependencies if
they're not generating Rust code with smithy-rs.

So far this module contains only the smithy.rust#serde trait definition. Its
implementation now resides in decorators in codegen-client and
codegen-server, respectively, but since the actual logic is identical, the
actual implementation is shared from codegen-core.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

@david-perez david-perez marked this pull request as ready for review October 30, 2024 16:50
@david-perez david-perez requested review from a team as code owners October 30, 2024 16:50
@smithy-lang smithy-lang deleted a comment from github-actions bot Oct 30, 2024
Copy link
Collaborator

@rcoh rcoh left a comment

Choose a reason for hiding this comment

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

  • need to figure out the opt-in story (and how we ensure the Rust SDK isn't opted in by accident)
  • Need to figure out the testing story for the clients. I don't think its sufficient to only smoke test the client given the shape-generation divergence.

@@ -72,6 +73,7 @@ class RustClientCodegenPlugin : ClientDecoratableBuildPlugin() {
IdempotencyTokenDecorator(),
StalledStreamProtectionDecorator(),
StaticSdkFeatureTrackerDecorator(),
ClientSerdeDecorator(),
Copy link
Collaborator

Choose a reason for hiding this comment

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

so this turns it on by default for all clients? I'm a little worried this would accidentally start generating serializers for the Rust SDK if a team ever exported the serde trait in their model. I think we need to make this opt-in in some way, e.g. via a codegen setting if we are going to bundle it like this.

Comment on lines +19 to +24
/**
* The serde decorators for the client and the server are _identical_, but they live in separate Gradle projects.
* There's no point in testing everything twice, since the code is the same. Hence this file just contains a simple
* smoke test to ensure we don't disable the client decorator _somehow_; all tests testing the decorator's logic should
* live in `SerdeDecoratorTest` of the `codegen-server` project instead.
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

this isn't really true. The code they generate is identical but client and server shapes are not the same—we really need to test against both.

/**
* The entrypoint to both the client and server decorators.
*/
fun extrasCommon(
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we rename this something related to serde—just because it's being called from an external context.

serdeExtras maybe?

class SerializeImplGenerator(private val codegenContext: CodegenContext) {
class SerializeImplGenerator(
private val codegenContext: CodegenContext,
private val unwrapConstraints: (Shape) -> Writable,
Copy link
Collaborator

Choose a reason for hiding this comment

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

this this is now a public name, we should probably name it better. It's not actually "unwrapping" constraints in that it doesn't fail if the constraints are violated. Maybe constrainedShapeToInner or something?

@@ -364,8 +379,8 @@ class SerdeDecoratorTest {
"e": "A",
"nested": {
"int": 5,
"float": "-Infinity",
Copy link
Collaborator

Choose a reason for hiding this comment

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

are there any remaining tests of the stringified floats?

Copy link

A new generated diff is ready to view.

  • No codegen difference in the AWS SDK
  • No codegen difference in the Client Test
  • No codegen difference in the Server Test
  • No codegen difference in the Server Test Python
  • No codegen difference in the Server Test Typescript

A new doc preview is ready to view.

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.

2 participants