Skip to content

Commit 29ea683

Browse files
committed
Fix build error
1 parent 51f473d commit 29ea683

File tree

1 file changed

+10
-8
lines changed
  • src/DynamoDBGenerator.SourceGenerator/Generations/Marshalling

1 file changed

+10
-8
lines changed

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

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,36 +122,36 @@ private static CodeFactory CreateMethod(ITypeSymbol type, Func<ITypeSymbol, Dyna
122122
SingleGeneric.SupportedType.Array => signature
123123
.CreateScope(
124124
$"if ({ParamReference} is null)"
125-
.CreateScope($"return {IsNull(singleGeneric)};")
125+
.CreateScope(IsNull(singleGeneric))
126126
.Append($"return {AttributeValueUtilityFactory.FromArray}({ParamReference}, {MarshallerOptions.ParamReference}, {DataMember}, static (a, o, d) => {InvokeMarshallerMethod(singleGeneric.T, "a", "d", options, "o")}{(singleGeneric.T.IsNullable() ? $" ?? {AttributeValueUtilityFactory.Null}" : null)});")
127127
).ToConversion(singleGeneric.T),
128128
SingleGeneric.SupportedType.List => signature
129129
.CreateScope(
130130
$"if ({ParamReference} is null)"
131-
.CreateScope($"return {IsNull(singleGeneric)};")
131+
.CreateScope(IsNull(singleGeneric))
132132
.Append($"return {AttributeValueUtilityFactory.FromList}({ParamReference}, {MarshallerOptions.ParamReference}, {DataMember}, static (a, o, d) => {InvokeMarshallerMethod(singleGeneric.T, "a", "d", options, "o")}{(singleGeneric.T.IsNullable() ? $" ?? {AttributeValueUtilityFactory.Null}" : null)});")
133133
).ToConversion(singleGeneric.T),
134134
SingleGeneric.SupportedType.IReadOnlyCollection
135135
or SingleGeneric.SupportedType.IEnumerable
136136
or SingleGeneric.SupportedType.ICollection => signature
137137
.CreateScope(
138138
$"if ({ParamReference} is null)"
139-
.CreateScope($"return {IsNull(singleGeneric)};")
139+
.CreateScope(IsNull(singleGeneric))
140140
.Append($"return {AttributeValueUtilityFactory.FromEnumerable}({ParamReference}, {MarshallerOptions.ParamReference}, {DataMember}, static (a, o, d) => {InvokeMarshallerMethod(singleGeneric.T, "a", "d", options, "o")}{(singleGeneric.T.IsNullable() ? $" ?? {AttributeValueUtilityFactory.Null}" : null)});")
141141
).ToConversion(singleGeneric.T),
142142
SingleGeneric.SupportedType.Set when singleGeneric.T.SpecialType is SpecialType.System_String
143143
=> signature
144144
.CreateScope(
145145
$"if ({ParamReference} is null)"
146-
.CreateScope($"return {IsNull(singleGeneric)};")
146+
.CreateScope(IsNull(singleGeneric))
147147
.Append($"return new {Constants.AWSSDK_DynamoDBv2.AttributeValue} {{ SS = new List<{(singleGeneric.T.IsNullable() ? "string?" : "string")}>({(singleGeneric.T.IsNullable() ? ParamReference : $"{ParamReference}.Select((y,i) => y ?? throw {ExceptionHelper.NullExceptionMethod}($\"{{{DataMember}}}[UNKNOWN]\"))")})}};")
148148
)
149149
.ToConversion(singleGeneric.T),
150150
SingleGeneric.SupportedType.Set when singleGeneric.T.IsNumeric()
151151
=> signature
152152
.CreateScope(
153153
$"if ({ParamReference} is null)"
154-
.CreateScope($"return {IsNull(singleGeneric)};")
154+
.CreateScope(IsNull(singleGeneric))
155155
.Append($"return new {Constants.AWSSDK_DynamoDBv2.AttributeValue} {{ NS = new List<string>({ParamReference}.Select(y => y.ToString())) }};")
156156
)
157157
.ToConversion(singleGeneric.T),
@@ -165,14 +165,14 @@ SingleGeneric.SupportedType.Set when singleGeneric.T.IsNumeric()
165165
KeyValueGeneric.SupportedType.Dictionary => signature
166166
.CreateScope(
167167
$"if ({ParamReference} is null)"
168-
.CreateScope($"return {IsNull(keyValueGeneric)};")
168+
.CreateScope($"{IsNull(keyValueGeneric)};")
169169
.Append($"return {AttributeValueUtilityFactory.FromDictionary}({ParamReference}, {MarshallerOptions.ParamReference}, {DataMember}, static (a, o, d) => {InvokeMarshallerMethod(keyValueGeneric.TValue, "a", "d", options, "o")}{(keyValueGeneric.TValue.IsNullable() ? $" ?? {AttributeValueUtilityFactory.Null}" : null)});")
170170
)
171171
.ToConversion(keyValueGeneric.TValue),
172172
KeyValueGeneric.SupportedType.LookUp => signature
173173
.CreateScope(
174174
$"if ({ParamReference} is null)"
175-
.CreateScope($"return {IsNull(keyValueGeneric)};")
175+
.CreateScope($"{IsNull(keyValueGeneric)};")
176176
.Append($"return {AttributeValueUtilityFactory.FromLookup}({ParamReference}, {MarshallerOptions.ParamReference}, {DataMember}, static (a, o, d) => {InvokeMarshallerMethod(keyValueGeneric.TValue, "a", "d", options, "o")}{(keyValueGeneric.TValue.IsNullable() ? $" ?? {AttributeValueUtilityFactory.Null}" : null)});")
177177
)
178178
.ToConversion(keyValueGeneric.TValue),
@@ -193,7 +193,9 @@ private static string CreateSignature(ITypeSymbol typeSymbol, MarshallerOptions
193193

194194
private static string IsNull(TypeIdentifier typeIdentifier)
195195
{
196-
return typeIdentifier.TypeSymbol.IsNullable() ? "null" : $"throw {ExceptionHelper.NullExceptionMethod}({DataMember})";
196+
return typeIdentifier.TypeSymbol.IsNullable()
197+
? "return null;"
198+
: $"throw {ExceptionHelper.NullExceptionMethod}({DataMember});";
197199
}
198200
private static IEnumerable<string> InitializeDictionary(IEnumerable<string> capacityCalculations)
199201
{

0 commit comments

Comments
 (0)