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

How Should Nullable And Optional Properties Be Handled During Deserialization? #4851

Open
jorgerangel-msft opened this issue Oct 24, 2024 · 0 comments
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Comments

@jorgerangel-msft
Copy link
Contributor

jorgerangel-msft commented Oct 24, 2024

Discussion arose from #4850.

MGC currently follows autorest for building the deserialization method of a model. For properties that are nullable and not collections, we generate a check for the json element to see if it's value is Null and then assign the corresponding property to null. This can be redundant in most cases since properties in the method are initialized using their default value ie. int? someInt = default.

Is this check still necessary? If the spec says a property is not nullable, is there still a need for adding this check?

@jorgerangel-msft jorgerangel-msft added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp
Projects
None yet
Development

No branches or pull requests

1 participant