Skip to content

Phase 2 final operations #3949

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

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open

Conversation

peterrsongg
Copy link
Contributor

@peterrsongg peterrsongg commented Aug 7, 2025

Description

Generator + custom code changes - 4642adf
Generated Changes - e19e49d

Generates the following operations

GetObjectAcl
HeadObject
ListObjectVersions
PutBucketAcl
PutBucketCors
PutObjectAcl
ListObjectsV2

I had to add more customization hooks to get this to generate correctly. For ListObjectsV2 and ListObjectVersions we were doing some weird stuff where we would change the type of a member and use a different member's unmarshaller to unmarhshall it. I'll make a comment in the PR to make it clear, but that is why I had to add the InjectXmlUnmarshallCode customization, so that we can inject some custom code into the unmarshallers.

I purposefully left out UploadPartCopy because I want to give that its own PR because it seems like too much to fit into this PR.

Motivation and Context

Testing

DRY_RUN-2ff2f349-de26-4a96-a09c-1858198f835f passed (08/07/2025)
The backwards compatibility comparer only output new methods/new types added which is backwards compatible.

AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.CommonPrefix/TypeAdded: New type Amazon.S3.Model.CommonPrefix
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataRequest/MethodAdded: New method System.String get_Range() in Amazon.S3.Model.GetObjectMetadataRequest
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataRequest/MethodAdded: New method System.Void set_Range(System.String) in Amazon.S3.Model.GetObjectMetadataRequest
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.Void set_ContentDisposition(System.String) in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.String get_CacheControl() in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.String get_ServerSideEncryptionCustomerProvidedKeyMD5() in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.Void set_ContentLanguage(System.String) in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.String get_ContentLanguage() in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.Void set_CacheControl(System.String) in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.Void set_ServerSideEncryptionCustomerProvidedKeyMD5(System.String) in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.String get_ContentType() in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.Void set_ContentType(System.String) in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.String get_ContentDisposition() in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.Void set_ContentEncoding(System.String) in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.GetObjectMetadataResponse/MethodAdded: New method System.String get_ContentEncoding() in Amazon.S3.Model.GetObjectMetadataResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.ListVersionsResponse/MethodAdded: New method System.Void set_Encoding(Amazon.S3.EncodingType) in Amazon.S3.Model.ListVersionsResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.ListVersionsResponse/MethodAdded: New method Amazon.S3.EncodingType get_Encoding() in Amazon.S3.Model.ListVersionsResponse
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.DeleteMarkerEntry/TypeAdded: New type Amazon.S3.Model.DeleteMarkerEntry
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.PutCORSConfigurationRequest/MethodAdded: New method System.Void set_ContentMD5(System.String) in Amazon.S3.Model.PutCORSConfigurationRequest
AssemblyComparer AWSSDK.S3.New.dll: Message Amazon.S3.Model.PutCORSConfigurationRequest/MethodAdded: New method System.String get_ContentMD5() in Amazon.S3.Model.PutCORSConfigurationRequest

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

ListObjectsV2Response response = new ListObjectsV2Response();

while (context.Read())
//https://github.com/aws/aws-sdk-net/blob/79cbc392fc3f1c74fcdf34efd77ad681da8af328/sdk/src/Services/S3/Custom/Model/Internal/MarshallTransformations/ListObjectsV2ResponseUnmarshaller.cs#L75-L87
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i included the permalink here so we know not to get rid of this. This is why we need the InjectXmlUnmarshallCustomcode customization

@@ -495,20 +495,6 @@ using Amazon.Runtime.Internal.Util;

protected void GenerateRequestChecksumHandling(Operation operation, string requestContent)
{
// If the request has a Content-MD5 property and it's set by the user, copy the value to the header.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is so that we don't set the content-md5 header twice. I ran the generator for s3 control and confirmed that nothing changed.

We also have this code https://github.com/aws/aws-sdk-net-staging/blob/main/sdk/src/Core/Amazon.Runtime/Internal/Util/ChecksumUtils.cs#L157 which won't calculate the md5 checksum if one is provided, so we can be confident it won't overwrite it. If one isn't provided we will auto-calculate in the checksum handler.

<#+
if (!string.IsNullOrEmpty(member.Shape.XmlNamespace))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Grantee member of Grant S3 expects the namespace and prefix to be written, so we need to check the shape's xmlNamespace since the xmlNamespace data is on the shape and not the member. The protocol test models usually put the xmlNamespace data on the member, but S3 doesn't seem to do that so I made the update here.

@@ -33,7 +33,7 @@ private IEnumerable<string> GetServiceModelEnumValues(string enumName)
public void AssertConstantsMatch(IReflect constantClassType, string enumName)
{
var constantClassValues = new HashSet<string>(GetConstantClassValues(constantClassType));
var serviceModelEnumValues = new HashSet<string>(GetServiceModelEnumValues(enumName));
var serviceModelEnumValues = string.IsNullOrEmpty(_serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName)) ? GetServiceModelEnumValues(enumName) : GetServiceModelEnumValues(_serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since ObjectStorageClass was renamed to S3StorageClass, the model thinks that ObjectStorageClass doesn't exist. We have to account for this case by checking for the renamed shape instead.

@GarrettBeatty GarrettBeatty requested review from Copilot and removed request for Copilot August 7, 2025 17:31
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR generates new AWS S3 operations and adds customization hooks to the generator to support additional marshalling/unmarshalling scenarios. The changes enable generation of GetObjectAcl, HeadObject, ListObjectVersions, PutBucketAcl, PutBucketCors, PutObjectAcl, and ListObjectsV2 operations by adding necessary customizations and refactoring existing custom code to work with generated models.

Key changes include:

  • Extended the generator with new customization hooks for XML unmarshalling code injection
  • Refactored S3 custom models to use partial classes to integrate with generated code
  • Updated generator logic to support excluding properties from unmarshalling and adding custom post-unmarshalling methods

Reviewed Changes

Copilot reviewed 27 out of 125 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
sdk/test/UnitTests/Custom/ConstantClassTestBase.cs Updated to handle shape name overrides for enum constants
sdk/src/Services/S3/Custom/Model/S3ObjectVersion.cs Converted to partial class and removed generated properties
sdk/src/Services/S3/Custom/Model/S3Object.cs Converted to partial class and removed generated properties
sdk/src/Services/S3/Custom/Model/S3AccessControlList.cs Converted to partial class and updated field references
sdk/src/Services/S3/Custom/Model/ListVersionsResponse.cs Removed custom implementation (now generated)
Multiple unmarshaller files Converted to partial classes or removed (now generated)
sdk/src/Services/S3/Custom/Model/GetObjectMetadataResponse.cs Converted to partial class and removed generated properties
sdk/src/Services/S3/Custom/Model/GetObjectMetadataRequest.cs Converted to partial class and removed generated properties
generator/ServiceModels/s3/s3.customizations.json Added extensive customizations for new operations
generator/ServiceClientGeneratorLib/ServiceModel.cs Enabled new S3 operations in allow list
Multiple generator files Added support for new customization features

@@ -33,7 +33,7 @@ private IEnumerable<string> GetServiceModelEnumValues(string enumName)
public void AssertConstantsMatch(IReflect constantClassType, string enumName)
{
var constantClassValues = new HashSet<string>(GetConstantClassValues(constantClassType));
var serviceModelEnumValues = new HashSet<string>(GetServiceModelEnumValues(enumName));
var serviceModelEnumValues = string.IsNullOrEmpty(_serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName)) ? GetServiceModelEnumValues(enumName) : GetServiceModelEnumValues(_serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName));
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] This ternary operator creates a complex nested call that's difficult to read. Consider extracting the override shape name to a variable first for better readability.

Suggested change
var serviceModelEnumValues = string.IsNullOrEmpty(_serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName)) ? GetServiceModelEnumValues(enumName) : GetServiceModelEnumValues(_serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName));
var overrideShapeName = _serviceModelUnderTest.Customizations.GetOverrideShapeName(enumName);
var serviceModelEnumValues = string.IsNullOrEmpty(overrideShapeName)
? GetServiceModelEnumValues(enumName)
: GetServiceModelEnumValues(overrideShapeName);

Copilot uses AI. Check for mistakes.

{
foreach (var grant in grantList)
foreach (var grant in _grants)
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same issue as above - using '_grants' field name that doesn't appear to be defined in this partial class. This will likely cause a compilation error.

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

1 participant