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

[tcgc] overwrite original value when set multiple value for same decorator #1606

Merged
merged 12 commits into from
Oct 11, 2024

Conversation

tadelesh
Copy link
Member

fix: #1036

@azure-sdk
Copy link
Collaborator

azure-sdk commented Sep 25, 2024

All changed packages have been documented.

  • @azure-tools/typespec-client-generator-core
Show changes

@azure-tools/typespec-client-generator-core - fix ✏️

overwrite original value when set multiple value for same decorator

@azure-sdk
Copy link
Collaborator

You can try these changes here

🛝 Playground 🌐 Website 📚 Next docs

@tadelesh
Copy link
Member Author

@timotheeguerin could you help to have a review?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

yes. all client decorator value should be scope orthometric. they should always be used in client.tsp, so augment decorator is more common.

Copy link
Member

Choose a reason for hiding this comment

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

That is an azure decision though to have that client.tsp. Someone else could decide to use it inline.

Copy link
Member Author

Choose a reason for hiding this comment

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

got it. if the value could overlap each other, then the order should be important, which may be confuse for customer i think. let me raise this discussion in the weekly sync after our national holiday.

Copy link
Member

Choose a reason for hiding this comment

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

Just for clarity on the ideal design for decorators:

  • Order on the element itself shouldn't be depended on. It is confusing(inverted). And if you don't allow multiple decorators(you just override) it is good to validate you don't define those twice
  • Using the decorator on model is or op is to override the base model/op should work and not complain about duplicate
  • Similarly using augment decorator to override what is defined locally shouldn't ideally complain either
  • Multiple augment decorator are run in the order of declaration so later overrides. I think it can be ok to validate to don't augment twice but you might have to be careful also on the scope. E.g. if a library augmented a type and you want to reaugment it again might not want it to complain again.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok, i got what you mean. then i think it is more effort than it's worth to check duplicate definition. i will change the logic to be incremental setting for all settings for one decorator, overwrite when same scope. what do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

i've changed the logic, please help to review.

@tadelesh tadelesh changed the title [tcgc] support duplicate decorator check on augment decorator [tcgc] overwrite original value when set multiple value for same decorator Oct 9, 2024
@iscai-msft
Copy link
Contributor

@tadelesh the release just went out, I feel it would be good to release this before next month's release, thoughts on updating this to the release branch?

@tadelesh tadelesh changed the base branch from main to release/october-2024 October 10, 2024 14:48
@tadelesh
Copy link
Member Author

@tadelesh the release just went out, I feel it would be good to release this before next month's release, thoughts on updating this to the release branch?

sure. changed branch.

@iscai-msft iscai-msft merged commit 5c68be1 into release/october-2024 Oct 11, 2024
22 checks passed
@iscai-msft iscai-msft deleted the fix_decorator_check branch October 11, 2024 12:59
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.

[Bug]: precedence/ordering of @@access decorators is unclear
4 participants