-
Notifications
You must be signed in to change notification settings - Fork 867
Add Initial support for CBOR protocol including extension package and Marshaller generators #3879
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
base: cbor-protocol
Are you sure you want to change the base?
Add Initial support for CBOR protocol including extension package and Marshaller generators #3879
Conversation
private static readonly ConcurrentBag<CborWriter> _pool = new ConcurrentBag<CborWriter>(); | ||
|
||
// Maximum number of CborWriter instances the pool can hold | ||
private static int _maxPoolSize = 16; |
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.
The current value of _maxPoolSize
is temporary, I need evaluate and test it more before merging the feature branch.
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.
just some minor comments, but also it's kind of hard to tell if it is working correctly or not without the protocol tests for the marshallers. Were you planning on adding that as part of this PR?
</Choose> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Formats.Cbor" Version="9.0.5" /> |
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 a general question, but do you have plans to also include these new dependencies in the build system when copying over the dll's? I had to do that when adding System.Text.JSON as an example
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.
Should part of the build system task that we added, will mention that on the task's decription so we don't miss that.
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks> |
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.
Do we need netcoreapp3.1 in here if cbor is only supported in net8 and netstandard?
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 should work on netcoreapp3.1
too, it will just show a warning.
return; | ||
} | ||
|
||
if (value % 1 == 0) |
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.
is this safe to do? I don't know much about CBOR but it seems that if the user passes in a float value they'd want to keep that extra precision instead of writing it as an int. Am I missing something here? Since it is binary does it not matter?
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.
When if (value % 1 == 0)
is true, then we don't have anything after the decimal point to keep. It was part of the SEP to send the numbers as the smallest version possible that doesn't lose any data.
/// </summary> | ||
/// <param name="input"></param> | ||
/// <returns></returns> | ||
public IRequest Marshall(AmazonWebServiceRequest input) |
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.
whitespace seems to be off here. or is it just the github ui?
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.
Probably, It looks good when generated though which should matter more, will double check if I can do something about it without messing up the generated files.
throw new System.InvalidOperationException("TargetPrefix is required for CBOR based services."); | ||
} | ||
#> | ||
request.ResourcePath = "<#=$"service/{this.Config.ServiceModel.TargetPrefix}/operation/{this.Operation.Name}"#>"; |
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.
What about the prefix? The SEP states it as a MUST
Every request for the rpcv2Cbor protocol MUST be sent to a URL with the following form: {prefix?}/service/{serviceName}/operation/{operationName}
I couldn't find in the cloudwatch logs service model where to even get this prefix though
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.
Yeah this is something I talked about with the SEP writers in the CBOR channel, it doesn't exist now for CloudWatch but it must be added before it uses CBOR.
Also there is additional details in the SEP few lines after the line you quoted, and it mentions how the serviceName
can be found for smithy and that for C2J it should be TargetPrefix
, thats why I added this exception to be safe if they forgot to add it for some reason.
using AWSSDK.Extensions.CborProtocol.Internal; | ||
|
||
#pragma warning disable CS0612,CS0618 | ||
namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformations |
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: weird spacing here?
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.
Maybe another github UI thing, will double check this one too.
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.
@peterrsongg I understand that verifiying that everything work is kinda hard, but this PR is already big enough that I didn't want and increase its size with the Protocol tests which are my next task. Though did some manual testing with the services to be sure.
Also we are targetting a feature branch here, so rest assured that we don't release this without the Protocol tests :D
</Choose> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="System.Formats.Cbor" Version="9.0.5" /> |
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.
Should part of the build system task that we added, will mention that on the task's decription so we don't miss that.
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks> |
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 should work on netcoreapp3.1
too, it will just show a warning.
return; | ||
} | ||
|
||
if (value % 1 == 0) |
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.
When if (value % 1 == 0)
is true, then we don't have anything after the decimal point to keep. It was part of the SEP to send the numbers as the smallest version possible that doesn't lose any data.
throw new System.InvalidOperationException("TargetPrefix is required for CBOR based services."); | ||
} | ||
#> | ||
request.ResourcePath = "<#=$"service/{this.Config.ServiceModel.TargetPrefix}/operation/{this.Operation.Name}"#>"; |
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.
Yeah this is something I talked about with the SEP writers in the CBOR channel, it doesn't exist now for CloudWatch but it must be added before it uses CBOR.
Also there is additional details in the SEP few lines after the line you quoted, and it mentions how the serviceName
can be found for smithy and that for C2J it should be TargetPrefix
, thats why I added this exception to be safe if they forgot to add it for some reason.
using AWSSDK.Extensions.CborProtocol.Internal; | ||
|
||
#pragma warning disable CS0612,CS0618 | ||
namespace <#= this.Config.Namespace #>.Model.Internal.MarshallTransformations |
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.
Maybe another github UI thing, will double check this one too.
/// </summary> | ||
/// <param name="input"></param> | ||
/// <returns></returns> | ||
public IRequest Marshall(AmazonWebServiceRequest input) |
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.
Probably, It looks good when generated though which should matter more, will double check if I can do something about it without messing up the generated files.
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.
Approving, knowing that this may change when the protocol tests are added
Description
This PR introduces foundational support for the smithy-rpc-v2-cbor protocol in the AWS SDK for .NET. The changes are structured across three commits:
System.Formats.Cbor
from the Core SDK and keeps non-CBOR services unaffected.Motivation and Context
DOTNET-8158
DOTNET-8159
DOTNET-8160
Testing
Added
smithy-rpc-v2-cbor
to few service modelsprotocols
, generated the marshallers, executed some requests using these marshallers and validated that the serialized content is as expected and that the requests were handled correctly by these services.Screenshots (if appropriate)
Types of changes
License