[TCGC] Handle encodedAs from @encode for all types - #5146
Merged
Conversation
iscai-msft
requested review from
Laurent Mazuel (lmazuel),
m-nash,
Mark Cowlishaw (markcowl),
Timothee Guerin (timotheeguerin) and
Jeff Fisher (xirzec)
as code owners
August 3, 2026 18:08
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
Contributor
|
You can try these changes here
|
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Extend addEncodeInfo to handle string and url types with @encode, so that @encode("abc", int32) on a string property correctly sets encode="abc" and wireType=int32. Also preserve the existing behavior for int/boolean encoded as string. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
encodedAs from @encode for all types
Add test that mirrors the issue's playground example with both @encode(ArrayEncoding.commaDelimited) on string[] and @encode("abc", int32) on string in the same model. Also add valueType.encode verification to existing array encode test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Chenjie Shi (tadelesh)
approved these changes
Aug 5, 2026
Chenjie Shi (tadelesh)
left a comment
Member
There was a problem hiding this comment.
Could you help to check if this will impact lanague's emitter before merge?
iscai-msft
enabled auto-merge
August 6, 2026 15:56
Contributor
📦 Package size report4 packages changed size compared to the base branch.
41 unchanged package(s)
Packed = gzipped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix
Fixes #3659
The
@encodedecorator'sencodedAsparameter was not being taken into account correctly for all types. For example,@encode("abc", int32)on astringproperty was silently ignored — noencodeorwireTypewas set.Changes
wireType?: SdkBuiltInTypetoSdkBuiltInTypeinterface so encode wire type info is available for all built-in types (previously only datetime/duration hadwireType)addEncodeInfoto handle@encodeforstring,url,int*,boolean, andbytestypes:encodefrom the encoding namewireTypefrom theencodedAstype parameter@encode("abc", int32)on string properties (new case from the issue)wireTypeassertions on existing int/boolean encode tests