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 hook for CodegenDecorators to insert a custom symbol provider #2434

Merged
merged 5 commits into from
Mar 8, 2023

Conversation

mcmasn-amzn
Copy link
Contributor

@mcmasn-amzn mcmasn-amzn commented Mar 5, 2023

Motivation and Context

#2158

Description

This provides a new hook on the CoreCodegenDecorator interface. This allows authors of custom decorators (like myself) to manipulate symbols when they are being built.

For example -- this allows me to insert extra derives (such as serde::Deserialize).

Testing

  • Ensured all tests are passing locally ./gradlew test
  • Rebuilt the package with my custom decorator and verified my decorator receives the expected callback.

Checklist

No updates to changelog. This is an internal change that shouldn't affect most users.


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
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

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

Nice! This looks good. Just a minor comment on naming.

@mcmasn-amzn
Copy link
Contributor Author

I see all CI checks pass except 1, "CI (from fork) / ci / Check SDK Examples (pull_request) ". I don't understand the failure on this check. Is this related to my change? Or is it a known issue in this test?

https://github.com/awslabs/smithy-rs/actions/runs/4356033052/jobs/7613678073#step:3:1597

Checking cfg-if v1.0.0
error[E0463]: can't find crate for core
|
= note: the wasm32-unknown-unknown target may not be installed
= help: consider downloading the target with rustup target add wasm32-unknown-unknown

error[E0463]: can't find crate for compiler_builtins

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.

LGTM—see one suggestion about removing model. Final approval delegated to @jdisanti

@jdisanti
Copy link
Collaborator

jdisanti commented Mar 7, 2023

I see all CI checks pass except 1, "CI (from fork) / ci / Check SDK Examples (pull_request) ". I don't understand the failure on this check. Is this related to my change? Or is it a known issue in this test?

This failure isn't related to your PR, and won't block merging.

@mcmasn-amzn
Copy link
Contributor Author

cool, thank you for the review @jdisanti

@Velfi Velfi added this pull request to the merge queue Mar 8, 2023
Merged via the queue into smithy-lang:main with commit fdec05b Mar 8, 2023
@mcmasn-amzn mcmasn-amzn deleted the custom-derives branch April 14, 2023 14:02
Velfi pushed a commit that referenced this pull request Apr 19, 2023
## Motivation and Context
Follow-up to #2434


## Description
This provides a way to fix a compiler warning. Attributes created using
RustMetadata.additionalAttributes may trigger compiler warnings
(rust-lang/rust#79202) such as

```
warning: derive helper attribute is used before it is introduced
    --> src/model.rs:7674:3
     |
7674 | #[serde(tag = "_type", content = "_content")]
     |   ^^^^^
7675 | #[derive(
7676 |     serde::Deserialize,
     |     ------------------ the attribute is introduced here
     |
     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
     = note: for more information, see issue #79202 <rust-lang/rust#79202>

```

## Testing
Added a unit test to validate the sort order is applied correctly to
Attributes with isDeriveHelper = true.

---------

Co-authored-by: david-perez <[email protected]>
unexge pushed a commit that referenced this pull request Apr 24, 2023
## Motivation and Context
Follow-up to #2434


## Description
This provides a way to fix a compiler warning. Attributes created using
RustMetadata.additionalAttributes may trigger compiler warnings
(rust-lang/rust#79202) such as

```
warning: derive helper attribute is used before it is introduced
    --> src/model.rs:7674:3
     |
7674 | #[serde(tag = "_type", content = "_content")]
     |   ^^^^^
7675 | #[derive(
7676 |     serde::Deserialize,
     |     ------------------ the attribute is introduced here
     |
     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
     = note: for more information, see issue #79202 <rust-lang/rust#79202>

```

## Testing
Added a unit test to validate the sort order is applied correctly to
Attributes with isDeriveHelper = true.

---------

Co-authored-by: david-perez <[email protected]>
rcoh pushed a commit that referenced this pull request Apr 24, 2023
## Motivation and Context
Follow-up to #2434


## Description
This provides a way to fix a compiler warning. Attributes created using
RustMetadata.additionalAttributes may trigger compiler warnings
(rust-lang/rust#79202) such as

```
warning: derive helper attribute is used before it is introduced
    --> src/model.rs:7674:3
     |
7674 | #[serde(tag = "_type", content = "_content")]
     |   ^^^^^
7675 | #[derive(
7676 |     serde::Deserialize,
     |     ------------------ the attribute is introduced here
     |
     = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
     = note: for more information, see issue #79202 <rust-lang/rust#79202>

```

## Testing
Added a unit test to validate the sort order is applied correctly to
Attributes with isDeriveHelper = true.

---------

Co-authored-by: david-perez <[email protected]>
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