-
Notifications
You must be signed in to change notification settings - Fork 863
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
Update marshallers to use system text json #3528
Conversation
{ | ||
JsonWriter writer = new JsonWriter(streamWriter); | ||
writer.Validate = false; | ||
#if !NETCOREAPP3_1_OR_GREATER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rewrite this part to the following for simplicity? or would this change affect the behavior?
#if NETCOREAPP3_1_OR_GREATER
ArrayBufferWriter<byte> arrayBufferWriter = new ArrayBufferWriter<byte>();
using Utf8JsonWriter writer = new Utf8JsonWriter(arrayBufferWriter);
#else
using var memoryStream = new MemoryStream();
using Utf8JsonWriter writer = new Utf8JsonWriter(memoryStream);
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It shouldn't change the behavior, I will change it for readability, thanks!
} | ||
|
||
request.Content = memoryStream.ToArray(); | ||
#if !NETCOREAPP3_1_OR_GREATER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I would prefer if we start with #if NETCOREAPP3_1_OR_GREATER
condition instead of using the not version.
@@ -54,18 +54,18 @@ namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformat | |||
string memberProperty = variableName + "." + member.PropertyName + (member.IsNullable ? ".Value" : string.Empty); | |||
if(member.IsStructure || member.IsList || member.IsMap) | |||
{ | |||
this.ProcessStructure(level, variableName + "." + member.PropertyName, member.Shape); | |||
this.ProcessStructure(level + 1, variableName + "." + member.PropertyName, member.Shape); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this change, the generated files looks fine but I want to understand how it used to work before without the +1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually something I just noticed while scanning through the marshallers. It was incorrectly not indented one level so I fixed it
verified that the changes don't affect behavior. Merging |
* Serialization changes for System Text Json
* Serialization changes for System Text Json
* Serialization changes for System Text Json
Description
This is part 1 of a multi-part PR to update the AWS SDK for .NET to use system text json for all json based protocols. This PR focuses only on the marshallers.
Motivation and Context
As described in an internal design document, system text json based serialization is much more efficient in both memory and cpu. Since we're doing a new major version which takes a dependency on system.text.json, we can make the upgrade now.
Testing
I ran the generator for all protocol test services, then ran all the protocol tests which all passed. I had to comment out the
JsonSampleGenerator
class to get the protocol tests to run. That class will be refactored as part of another PR.As for formatting of the marshallers I went through each generated marshaller and fixed spacing and formatting iteratively.
Final dry run will be done at the end of the PR.
Screenshots (if appropriate)
Types of changes
Checklist
License