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

Fix failing collection related tests for v4 dev #3312

Merged

Conversation

peterrsongg
Copy link
Contributor

@peterrsongg peterrsongg commented May 7, 2024

Description

With the initializeCollections flag set to false by default, this caused some protocol tests to fail. This fixes a couple issues.

  1. When comparing objects, if the initializeCollection flag is set to false then we will treat an empty collection and a null collection as the same (look at Comparer.CompareObjects for more detail)
  2. If initializeCollection is set to false, then when unmarshalling a dictionary or a list which is sent back by a service, create the collection as to not get NullReferenceExceptions
  3. If we are unmarshalling a collection and it is empty, then return a new instance of the collection if InitializeCollections is set to true, otherwise return null.

manual fixes - 6c259a9
generated fixes - 3e68e73

Motivation and Context

Testing

Fixes Failed Tests:

    QueryXmlEmptyListsResponse
    Ec2XmlEmptyListsResponse
    FlatNestedXmlMapResponseResponse
    QueryXmlEmptyMapsResponse
    FlattenedXmlMapResponse
    QueryXmlEmptySelfClosedMapsResponse
    HttpPrefixHeadersAreNotPresentResponse
    XmlEmptySelfClosedMapsResponse
    AwsJson10DeserializeAllowNullsResponse

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

@dscpinheiro dscpinheiro requested review from boblodgett and normj May 7, 2024 20:48
@dscpinheiro dscpinheiro added the v4 label May 7, 2024
@@ -183,6 +187,10 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
#>
if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>", targetDepth))
{
if (response.<#=member.PropertyName#> == null)
Copy link
Member

Choose a reason for hiding this comment

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

Same comment above about initializing collections.

@@ -51,6 +53,14 @@ private static void Compare(object x, object y, Type type)
if (x == null && y == null)
return;

if (x != null && x.GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICollection<>)) && !AWSConfigs.InitializeCollections)
Copy link
Member

Choose a reason for hiding this comment

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

The comparer should handle both possible boolean values for the InitializeCollections property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other if statements handle when InitializeCollections is true, but I did simplify the if statement and the statement below.

@peterrsongg peterrsongg requested a review from normj May 9, 2024 01:10
@peterrsongg peterrsongg force-pushed the petesong/v4-dev-fix-collection-protocol-tests branch from 6056d15 to fb91763 Compare May 9, 2024 01:29
@peterrsongg peterrsongg merged commit aff3507 into v4-development May 10, 2024
1 check passed
@peterrsongg peterrsongg deleted the petesong/v4-dev-fix-collection-protocol-tests branch May 10, 2024 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants