Skip to content

Commit d812014

Browse files
committed
Fix broken tests
1 parent 5772e4b commit d812014

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/DynamoDBGenerator.SourceGenerator/Generations/UnMarshaller.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,25 @@ private static CodeFactory CreateMethod(TypeIdentifier typeIdentifier, Func<ITyp
7575
if (options.TryReadConversion(typeIdentifier, Value) is {} conversion)
7676
{
7777
var signature = CreateSignature(typeIdentifier, options);
78-
return typeIdentifier.CanBeNull || typeIdentifier.IsSupposedToBeNull is false
79-
? signature
80-
.CreateScope(
81-
$"if ({Value} is null)"
82-
.CreateScope($"throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
83-
.Append(
84-
$"return {conversion} ?? throw {ExceptionHelper.NullExceptionMethod}({DataMember});"
85-
)
86-
)
87-
.ToConversion()
88-
: signature
78+
79+
if (typeIdentifier.IsSupposedToBeNull)
80+
return signature
8981
.CreateScope(
9082
$"if ({Value} is null)"
9183
.CreateScope("return null;")
9284
.Append($"return {conversion};")
9385
)
9486
.ToConversion();
87+
88+
return signature
89+
.CreateScope(
90+
$"if ({Value} is null)"
91+
.CreateScope($"throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
92+
.Append(
93+
$"return {conversion} ?? throw {ExceptionHelper.NullExceptionMethod}({DataMember});"
94+
)
95+
)
96+
.ToConversion();
9597
}
9698

9799
return typeIdentifier switch

0 commit comments

Comments
 (0)