Skip to content

Comments

Simplify StreamSerializationModelTemplate#2928

Merged
weidongxu-microsoft merged 4 commits intoAzure:mainfrom
alzimmermsft:SimplifyStreamStyleCode
Aug 27, 2024
Merged

Simplify StreamSerializationModelTemplate#2928
weidongxu-microsoft merged 4 commits intoAzure:mainfrom
alzimmermsft:SimplifyStreamStyleCode

Conversation

@alzimmermsft
Copy link
Member

Cleans up a lot of code in StreamSerializationModelTemplate by using an instance class to generate code. This removes the need to pass many parameters all over the place.

There is also a fix to generating fields in ModelTemplate by having the overload of getFieldProperties check if fromJsonShared can be used to determine whether the subclass should shade fields of a super class. The only time shading shouldn't happen with polymorphic types is when fromJsonShared can be used as those properties will be deserialized by the super type's fromJsonShared method, meaning the subtype doesn't need to shade.

@weidongxu-microsoft
Copy link
Member

weidongxu-microsoft commented Aug 21, 2024

test https://dev.azure.com/azure-sdk/internal/_build/results?buildId=4067144&view=results
Azure/azure-sdk-for-java#41571

@haolingdong-msft
Copy link
Member

haolingdong-msft commented Aug 23, 2024

Hi @alzimmermsft, I merged your pr with main branch to a feature branch, and tried to regenerate for TypeSpec SDKs based on the branch. I found API view diff like below, @override is removed from getKind() in subclass. I suppose after setting share-jsonserializable-code to false, there shoud be no diff. It seems a bug. Could u please check?
image

PR: Azure/azure-sdk-for-java#41617
diff example: https://github.com/Azure/azure-sdk-for-java/pull/41617/files#diff-90b30f05da823f3aaaf96caa3a6234d229c84b3e93c10224183857a36a9c3b02L63
autorest.java feature branch: https://github.com/Azure/autorest.java/tree/stream-style-fix-and-sdkpackage/typespec-extension

Thanks.

@weidongxu-microsoft weidongxu-microsoft merged commit 457aa34 into Azure:main Aug 27, 2024
@alzimmermsft alzimmermsft deleted the SimplifyStreamStyleCode branch August 27, 2024 12:37
weidongxu-microsoft added a commit to weidongxu-microsoft/typespec that referenced this pull request Aug 29, 2024
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