-
Notifications
You must be signed in to change notification settings - Fork 169
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
feat(common): support null value for reference type collection elements #3163
Merged
archerzz
merged 20 commits into
Azure:feature/v3
from
archerzz:common/null-collection-element
Mar 2, 2023
Merged
feat(common): support null value for reference type collection elements #3163
archerzz
merged 20 commits into
Azure:feature/v3
from
archerzz:common/null-collection-element
Mar 2, 2023
Conversation
This file contains 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
I believe we want to get your parallel work in before uploading the regen PR? If so lets mark this as draft until we get ready for that. |
m-nash
reviewed
Feb 22, 2023
samples/Azure.Management.Storage/Generated/Models/BlobInventoryPolicyFilter.Serialization.cs
Show resolved
Hide resolved
m-nash
approved these changes
Mar 1, 2023
3bba737
to
5cc8130
Compare
- update `SerializationBuilder` to set `ValueSerialization.IsNullable : true` for reference type collection elements - that will add null value handling in deserialization logic for collection elements of reference type - generate null check in generated serialization/deserialization codes for: - nullable value type - list/dictionary types - some framework reference types - optimize null value processing so that we don't generate null check codes - for custom model types, put null value processing logic into the deserialization method of each model - for string, use default serialization/deserialization methods which can handle null value - update `byte[]` serializatoin/deserialization methods so that they can handle null value, so that we don't generate null check codes externally - fix 3 test cases previously do not accept null value in collections in response, now we align with other language implementaion on that resolve Azure#3159
`WriteObjectValue` cannot cover all cases, so add the defensive null check just in case
5cc8130
to
6a9da34
Compare
Here is the generated preview PR: Azure/azure-sdk-for-net#34624 |
lirenhe
approved these changes
Mar 2, 2023
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.
SerializationBuilder
to setValueSerialization.IsNullable : true
for collection elements of reference typeSerializationWriter
so that in generated model deserialization methods, null value handling (return null if pass in null json value) is added at the beginningUtf8JsonWriterExtension.WriteBase64StringValue()
to handle null json value in serializationJsonElementExtension.GetBytesFromBase64()
to handle null json value in deserializationupdate
JsonCodeWriterExtension
, for collection items:Utf8JsonWriter.WriteStringValue()
which has null value supportbyte[]
is handled by the modifiedUtf8JsonWriterExtension.WriteBase64StringValue()
(see the change above)Utf8JsonWriterExtension.WriteObjectValue()
which has null value supportJsonElement.GetString()
byte[]
is handled byJsonElementExtension.GetBytesFromBase64()
resolve #3159
Serialization
if (value==null) { writer.WriteNullValue()}
if (value==null) { writer.WriteNullValue()}
if (value==null) { writer.WriteNullValue()}
Deserialization
if (element.Value.ValueKind == JsonValueKind.Null) { array.Add(null)}
if (element.Value.ValueKind == JsonValueKind.Null) { array.Add(null)}
if (element.Value.ValueKind == JsonValueKind.Null) { array.Add(null)}
Checklist
To ensure a quick review and merge, please ensure:
Ready to Land?