@@ -387,7 +387,8 @@ using Amazon.Runtime.Internal.Util;
387
387
protected string DetermineXmlMarshallName(Member member, bool withPrefix = true)
388
388
{
389
389
var locationName = member.data[ServiceModel.LocationNameKey];
390
- if (locationName == null)
390
+ // operation can be null if we're determining the xml marshall name for a structure
391
+ if (locationName == null && this.Operation != null)
391
392
{
392
393
var payload = this.Operation.ResponsePayloadMember;
393
394
var shouldMarshallPayload = (payload != null && payload.IsStructure);
@@ -402,12 +403,119 @@ using Amazon.Runtime.Internal.Util;
402
403
return colonIndex != -1 ? locationNameString.Substring(colonIndex + 1) : locationNameString;
403
404
}
404
405
// the locationName and modeled name must only be different for those members which are marshalled on the body.
405
- if (!string.Equals(locationName.ToString(), member.ModeledName, StringComparison.Ordinal) || member.MarshallLocation != MarshallLocation.Body)
406
- {
407
- return locationName.ToString();
408
- }
406
+ // S3 / S3 Control don't seem to follow this rule where the location name is used only if it doesn't match the member's name.
407
+ if (locationName != null)
408
+ {
409
+ if (this.Config.ServiceId == "S3" || this.Config.ServiceId == "S3 Control" || !string.Equals(locationName.ToString(), member.ModeledName, StringComparison.Ordinal) || member.MarshallLocation != MarshallLocation.Body)
410
+ {
411
+ return locationName.ToString();
412
+ }
413
+ }
414
+
415
+ // some structure members do not have a locationName.
416
+ // so if we get to this point, it is gauranteed that the marshall name we are determining is for a
417
+ // member of a structure. For a member of a structure the marshall name is straightforward.
418
+ if (locationName == null)
419
+ {
420
+ return member.MarshallName;
421
+ }
409
422
var memberTarget = member.Shape.data[ServiceModel.LocationNameKey];
410
423
411
424
return memberTarget != null ? memberTarget.ToString() : member.Shape.Name;
412
425
}
413
426
#>
427
+
428
+ <#+
429
+ /// Only to be used by rest-xml response unmarshallers
430
+ protected void ProcessResponseBodyOrStructureMembers(Member member, bool isStructure)
431
+ {
432
+ string unmarshalledVariable = isStructure ? "unmarshalledObject" : "response";
433
+ if (member.Shape.IsList)
434
+ {
435
+ var listMarshallName = member.Shape.ListMarshallName ?? "member";
436
+
437
+ if (member.IsFlattened || member.Shape.IsFlattened)
438
+ {
439
+ #>
440
+ if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>", targetDepth))
441
+ {
442
+ if (<#=unmarshalledVariable#>.<#=member.PropertyName#> == null)
443
+ {
444
+ <#=unmarshalledVariable#>.<#=member.PropertyName#> = new <#=member.DetermineType()#>();
445
+ }
446
+ var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
447
+ <#=unmarshalledVariable#>.<#=member.PropertyName#>.Add(unmarshaller.Unmarshall(context));
448
+ continue;
449
+ }
450
+ <#+
451
+ }
452
+ else
453
+ {
454
+ #>
455
+ if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>/<#=listMarshallName#>", targetDepth))
456
+ {
457
+ if (<#=unmarshalledVariable#>.<#=member.PropertyName#> == null)
458
+ {
459
+ <#=unmarshalledVariable#>.<#=member.PropertyName#> = new <#=member.DetermineType()#>();
460
+ }
461
+ var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
462
+ <#=unmarshalledVariable#>.<#=member.PropertyName#>.Add(unmarshaller.Unmarshall(context));
463
+ continue;
464
+ }
465
+ <#+
466
+ }
467
+ }
468
+ else if(member.Shape.IsMap)
469
+ {
470
+ if(member.IsFlattened)
471
+ {
472
+ #>
473
+ if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>", targetDepth))
474
+ {
475
+ if (response.<#=member.PropertyName#> == null)
476
+ {
477
+ response.<#=member.PropertyName#> = new <#=member.DetermineType()#>();
478
+ }
479
+ var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
480
+ <#=unmarshalledVariable#>.<#=member.PropertyName#>.Add(unmarshaller.Unmarshall(context));
481
+ continue;
482
+ }
483
+ <#+
484
+ }
485
+ else
486
+ {
487
+ #>
488
+ if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>", targetDepth))
489
+ {
490
+ var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
491
+ <#=unmarshalledVariable#>.<#=member.PropertyName#> = unmarshaller.Unmarshall(context);
492
+ continue;
493
+ }
494
+ <#+
495
+ }
496
+ }
497
+ else
498
+ {
499
+ if (!member.IsXmlAttribute)
500
+ {
501
+ #>
502
+ if (context.TestExpression("<#=DetermineXmlMarshallName(member)#>", targetDepth))
503
+ <#+
504
+ }
505
+ else
506
+ {
507
+ #>
508
+ if (context.TestExpression("@<#=DetermineXmlMarshallName(member, false)#>", targetDepth - 1))
509
+
510
+ <#+
511
+ }
512
+ #>
513
+ {
514
+ var unmarshaller = <#= member.DetermineTypeUnmarshallerInstantiate() #>;
515
+ <#=unmarshalledVariable#>.<#=member.PropertyName#> = unmarshaller.Unmarshall(context);
516
+ continue;
517
+ }
518
+ <#+
519
+ }
520
+ }
521
+ #>
0 commit comments