Skip to content

Commit 5a13648

Browse files
authored
Fix IsSet for ServerSideEncryptionMethod on InitiateMultipartUploadRequest. Add specific inject xml code customization hooks for getters & setters. Remove unused custom partials. (#3986)
* Add specific inject xml code customization hooks for getters, setters, and private member declarations. Delete any unused custom code files. * move multi-line code injection to custom method, fix IsSet for ServerSideEncryptionMethod on initiatemultipartuploadrequest * Fix s3.customizations.json * update customizations file
1 parent 71ec145 commit 5a13648

File tree

15 files changed

+586
-321
lines changed

15 files changed

+586
-321
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"services": [
3+
{
4+
"serviceName": "S3",
5+
"type": "patch",
6+
"changeLogMessages": [
7+
"Remove unused custom partials"
8+
]
9+
}
10+
]
11+
}

generator/ServiceClientGeneratorLib/Customizations.cs

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1427,17 +1427,102 @@ public class PropertyModifier
14271427
public const string AccessModifierKey = "accessModifier";
14281428
public const string InjectXmlUnmarshallCodeKey = "injectXmlUnmarshallCode";
14291429
public const string SkipContextTestExpressionUnmarshallingLogicKey = "skipContextTestExpressionUnmarshallingLogic";
1430+
public const string InjectXmlIsSetCodeKey = "injectXmlIsSet";
1431+
public const string InjectXmlPrivateMemberAssignmentKey = "injectXmlPrivateMemberAssignment";
1432+
public const string InjectXmlPropertyGetterKey = "injectXmlPropertyGetter";
1433+
public const string InjectXmlPropertySetterKey = "injectXmlPropertySetter";
1434+
public const string SkipSetterKey = "skipSetter";
1435+
1436+
14301437

14311438
private readonly string _modelPropertyName;
14321439
private readonly JsonData _modifierData;
14331440
private readonly HashSet<string> _injectXmlUnmarshallCode;
1441+
private readonly HashSet<string> _injectXmlIsSetCode;
1442+
private readonly HashSet<string> _injectXmlPrivateMemberAssignment;
1443+
private readonly HashSet<string> _injectXmlPropertyGetter;
1444+
private readonly HashSet<string> _injectedXmlPropertySetter;
1445+
private readonly bool _skipSetter;
1446+
14341447
internal PropertyModifier(string modelPropertyName, JsonData modifierData)
14351448
{
14361449
this._modelPropertyName = modelPropertyName;
14371450
this._modifierData = modifierData;
14381451
_injectXmlUnmarshallCode = ParseInjectXmlUnmarshallCode();
1452+
_injectXmlIsSetCode = ParseInjectXmlIsSetCode();
1453+
_injectXmlPrivateMemberAssignment = ParseInjectXmlPrivateMemberAssignment();
1454+
_injectXmlPropertyGetter = ParseInjectXmlGetter();
1455+
_injectedXmlPropertySetter = ParseInjectXmlPropertySetter();
1456+
_skipSetter = ParseXmlSkipSetter();
1457+
}
1458+
1459+
private bool ParseXmlSkipSetter()
1460+
{
1461+
var data = _modifierData[SkipSetterKey];
1462+
return data != null && data.IsBoolean ? (bool)data : false;
1463+
1464+
}
1465+
1466+
public bool SkipSetter { get { return _skipSetter; } }
1467+
1468+
private HashSet<string> ParseInjectXmlPropertySetter()
1469+
{
1470+
var data = _modifierData[InjectXmlPropertySetterKey]?.Cast<object>()
1471+
.Select(x => x.ToString());
1472+
1473+
return new HashSet<string>(data ?? new string[0]);
14391474
}
14401475

1476+
/// <summary>
1477+
/// Use this customization within a property modifier to inject code in the Setter for a property.
1478+
/// If this HashSet has values then the default setter will not be generated and this custom injected
1479+
/// code will be used instead.
1480+
/// </summary>
1481+
public HashSet<string> InjectXmlPropertySetter { get { return _injectedXmlPropertySetter; } }
1482+
1483+
private HashSet<string> ParseInjectXmlGetter()
1484+
{
1485+
var data = _modifierData[InjectXmlPropertyGetterKey]?.Cast<object>()
1486+
.Select(x => x.ToString());
1487+
1488+
return new HashSet<string>(data ?? new string[0]);
1489+
}
1490+
1491+
/// <summary>
1492+
/// Use this customization within a property modifier to inject code in the getter for a property.
1493+
/// If this HashSet has values then the default getter will not be generated and this custom injected
1494+
/// code will be used instead.
1495+
/// </summary>
1496+
public HashSet<string> InjectXmlPropertyGetter { get { return _injectXmlPropertyGetter; } }
1497+
1498+
private HashSet<string> ParseInjectXmlPrivateMemberAssignment()
1499+
{
1500+
var data = _modifierData[InjectXmlPrivateMemberAssignmentKey]?.Cast<object>()
1501+
.Select(x => x.ToString());
1502+
1503+
return new HashSet<string>(data ?? new string[0]);
1504+
}
1505+
1506+
/// <summary>
1507+
/// Use this customization within a property modifier to inject code in the private member assignment
1508+
/// for a property. If this HashSet has values then the default private member assignment will not be generated
1509+
/// and this custom injected code will be used instead.
1510+
/// </summary>
1511+
public HashSet<string> InjectXmlPrivateMemberAssignment { get { return _injectXmlPrivateMemberAssignment; } }
1512+
1513+
private HashSet<string> ParseInjectXmlIsSetCode()
1514+
{
1515+
var data = _modifierData[InjectXmlIsSetCodeKey]?.Cast<object>()
1516+
.Select(x => x.ToString());
1517+
1518+
return new HashSet<string>(data ?? new string[0]);
1519+
}
1520+
1521+
/// <summary>
1522+
/// Use this customization within a property modifier to inject code in the IsSet() method for a property
1523+
/// If this HashSet has values then the default IsSet() code will not be generated and this custom injected code will be used instead.
1524+
/// </summary>
1525+
public HashSet<string> InjectXmlIsSetCode { get { return _injectXmlIsSetCode; } }
14411526
/// <summary>
14421527
/// Returns the original property name of the renamed property
14431528
/// </summary>

generator/ServiceClientGeneratorLib/Generators/BaseGenerator.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,48 @@ protected void WriteInjectXmlUnmarshallCode(Member member, int level)
20742074
}
20752075

20762076

2077+
#line default
2078+
#line hidden
2079+
2080+
#line 625 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\BaseGenerator.tt"
2081+
2082+
// writes injected xml code. Call this when you know that the property modifier exists.
2083+
protected void WriteInjectXmlCode(HashSet<string> codeArray, int level)
2084+
{
2085+
foreach (var code in codeArray)
2086+
{
2087+
2088+
2089+
#line default
2090+
#line hidden
2091+
2092+
#line 632 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\BaseGenerator.tt"
2093+
this.Write(this.ToStringHelper.ToStringWithCulture(new string(' ', level * 4)));
2094+
2095+
2096+
#line default
2097+
#line hidden
2098+
2099+
#line 632 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\BaseGenerator.tt"
2100+
this.Write(this.ToStringHelper.ToStringWithCulture(code));
2101+
2102+
2103+
#line default
2104+
#line hidden
2105+
2106+
#line 632 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\BaseGenerator.tt"
2107+
this.Write("\r\n");
2108+
2109+
2110+
#line default
2111+
#line hidden
2112+
2113+
#line 633 "C:\Dev\Repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\BaseGenerator.tt"
2114+
2115+
}
2116+
}
2117+
2118+
20772119
#line default
20782120
#line hidden
20792121
}

generator/ServiceClientGeneratorLib/Generators/BaseGenerator.tt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,3 +622,15 @@ foreach (var member in docMembers)
622622
}
623623
}
624624
#>
625+
<#+
626+
// writes injected xml code. Call this when you know that the property modifier exists.
627+
protected void WriteInjectXmlCode(HashSet<string> codeArray, int level)
628+
{
629+
foreach (var code in codeArray)
630+
{
631+
#>
632+
<#=new string(' ', level * 4)#><#=code#>
633+
<#+
634+
}
635+
}
636+
#>

0 commit comments

Comments
 (0)