Skip to content

Commit e87895a

Browse files
committed
Add additonal ruling
1 parent d89deeb commit e87895a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/DynamoDBGenerator.SourceGenerator/Generations/Marshalling/Marshaller.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ internal static string InvokeMarshallerMethod(ITypeSymbol typeSymbol, string par
215215
return invocation;
216216

217217
if (typeSymbol.TypeIdentifier() is UnknownType)
218-
return typeSymbol.IsNullable()
219-
? $"{AttributeValueUtilityFactory.ToAttributeValue}({invocation})"
220-
: $"new {Constants.AWSSDK_DynamoDBv2.AttributeValue} {{ M = {invocation} }}";
218+
return $"{AttributeValueUtilityFactory.ToAttributeValue}({invocation})";
221219

222220
return invocation;
223221
}

src/DynamoDBGenerator/Internal/MarshallHelper.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics.CodeAnalysis;
34
using System.Linq;
45
using Amazon.DynamoDBv2.Model;
56
using static System.Runtime.InteropServices.CollectionsMarshal;
@@ -17,8 +18,11 @@ public static class MarshallHelper
1718
#pragma warning disable CS1591
1819
public static AttributeValue Null { get; } = new() { NULL = true };
1920

20-
public static AttributeValue? ToAttributeValue(Dictionary<string, AttributeValue>? dict) => dict is null
21-
? null
21+
[return: NotNullIfNotNull(nameof(dict))]
22+
public static AttributeValue? ToAttributeValue(
23+
[NotNullIfNotNull(nameof(dict))] Dictionary<string, AttributeValue>? dict
24+
) => dict is null
25+
? null
2226
: new AttributeValue { M = dict };
2327

2428
public static AttributeValue FromDictionary<T, TArgument>(

0 commit comments

Comments
 (0)