Skip to content

Commit 4af7d85

Browse files
Afroz Mohammedafroz429
authored andcommitted
updated c# syntax to work on older versions of dotnet
1 parent 68e26e6 commit 4af7d85

File tree

2 files changed

+4
-32
lines changed

2 files changed

+4
-32
lines changed

generator/AWSPSGeneratorLib/Utils/Extensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ public static bool IsSensitive(this PropertyInfo propertyInfo)
6060
/// </summary>
6161
public static bool ContainsSensitiveData(this Type type, HashSet<Type> visitedTypes = null)
6262
{
63-
visitedTypes ??= [];
63+
if (visitedTypes == null)
64+
visitedTypes = new HashSet<Type>();
6465

6566
if (!visitedTypes.Add(type))
6667
return false;

generator/AWSPSGeneratorLib/Writers/SourceCode/CmdletSourceWriter.cs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,12 @@ public void Write(IndentedTextWriter writer, string awsSignerAttributeTypeValue)
238238

239239
private void WriteSensitiveDataFlags(IndentedTextWriter writer)
240240
{
241-
if (ContainsSensitiveData(MethodAnalysis.RequestType))
241+
if (MethodAnalysis.RequestType.ContainsSensitiveData())
242242
{
243243
writer.WriteLine();
244244
writer.WriteLine("protected override bool IsSensitiveRequest { get; set; } = true;");
245245
}
246-
if (ContainsSensitiveData(MethodAnalysis.ResponseType))
246+
if (MethodAnalysis.ResponseType.ContainsSensitiveData())
247247
{
248248
writer.WriteLine();
249249
writer.WriteLine("protected override bool IsSensitiveResponse { get; set; } = true;");
@@ -255,35 +255,6 @@ private void WriteGeneratedCmdletFlag(IndentedTextWriter writer)
255255
writer.WriteLine("protected override bool IsGeneratedCmdlet { get; set; } = true;");
256256
}
257257

258-
/// <summary>
259-
/// Checks if the type contains any sensitive data by going recursivly over all the internal properties
260-
/// </summary>
261-
private bool ContainsSensitiveData(Type type, Dictionary<Type, bool> visitedTypes = null)
262-
{
263-
if (visitedTypes == null)
264-
visitedTypes = new Dictionary<Type, bool>();
265-
266-
if (visitedTypes.ContainsKey(type))
267-
return false;
268-
269-
visitedTypes.Add(type, true);
270-
271-
foreach (var childProperty in type.GetProperties())
272-
{
273-
if (IsSensitive(childProperty) || ContainsSensitiveData(childProperty.PropertyType, visitedTypes))
274-
return true;
275-
}
276-
return false;
277-
}
278-
279-
private bool IsSensitive(PropertyInfo propertyInfo)
280-
{
281-
dynamic awsPropertyAttribute = propertyInfo.GetCustomAttributes()
282-
.Where(attribute => attribute.GetType().FullName == "Amazon.Runtime.Internal.AWSPropertyAttribute").SingleOrDefault();
283-
284-
return awsPropertyAttribute != null && awsPropertyAttribute.Sensitive;
285-
}
286-
287258
private void WriteConverters(IndentedTextWriter writer, SimplePropertyInfo property, Param paramCustomization)
288259
{
289260
if (paramCustomization?.AutoConvert == Param.AutoConversion.ToBase64)

0 commit comments

Comments
 (0)