Skip to content

Commit cc3ba80

Browse files
committed
Stay more consistent with coalesce
1 parent 9feb51d commit cc3ba80

1 file changed

Lines changed: 2 additions & 12 deletions

File tree

src/DynamoDBGenerator.SourceGenerator/Generations/UnMarshaller.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,7 @@ private static CodeFactory CreateMethod(TypeIdentifier typeIdentifier, Func<ITyp
8989
.CreateScope(
9090
$"if ({Value} is null)"
9191
.CreateScope($"throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
92-
.Append($"var result = {conversion};")
93-
.Concat(
94-
"if (result is null)"
95-
.CreateScope($"throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
96-
)
97-
.Append("return result.Value;")
92+
.Append($"return {conversion} ?? throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
9893
)
9994
.ToConversion()
10095

@@ -112,12 +107,7 @@ private static CodeFactory CreateMethod(TypeIdentifier typeIdentifier, Func<ITyp
112107
.CreateScope(
113108
$"if ({Value} is null)"
114109
.CreateScope($"throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
115-
.Append($"var result = {conversion};")
116-
.Concat(
117-
"if (result is null)"
118-
.CreateScope($"throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
119-
)
120-
.Append("return result;")
110+
.Append($"return {conversion} ?? throw {ExceptionHelper.NullExceptionMethod}({DataMember});")
121111
)
122112
.ToConversion()
123113

0 commit comments

Comments
 (0)