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

Properly set inits on InputType's Properties #4587

Closed
jorgerangel-msft opened this issue Apr 17, 2024 · 2 comments · Fixed by microsoft/typespec#3238
Closed

Properly set inits on InputType's Properties #4587

jorgerangel-msft opened this issue Apr 17, 2024 · 2 comments · Fixed by microsoft/typespec#3238
Assignees
Labels

Comments

@jorgerangel-msft
Copy link
Member

There are still input types that are not deserialized correctly due to missing init accessors on their properties. All of the input types should be adjusted so their properties are deserialized correctly. Sample where this is be done correctly: here

@jorgerangel-msft jorgerangel-msft changed the title Properly set inits on InputTypes Properly set inits on InputType's Properties Apr 17, 2024
@ArcturusZhang
Copy link
Member

@jorgerangel-msft I think init is not enough. Since we may have cross-reference and/or self-reference in our json, they need to be internal set because in some circumstances we need to new the instance without value in one property and set it later because setting that missing property needs the current instance.
Examples of this case could be found when we are deserialization InputModelType's BaseModel and Properties property.

@ArcturusZhang ArcturusZhang self-assigned this Apr 26, 2024
@ArcturusZhang
Copy link
Member

And I think making these input types as record does not conflict with the concept that its properties could have setter.
Records are better during debugging because it has default ToString implemented.
But I am fine that they are classes right now anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants