Skip to content

Commit 4d1497d

Browse files
committed
Reuse IsUnknown
1 parent 455b3a2 commit 4d1497d

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,9 @@ internal static string InvokeMarshallerMethod(TypeIdentifier typeIdentifier, str
209209
{
210210
var invocation = $"{ClassName}.{GetSerializationMethodName(typeIdentifier.TypeSymbol)}({parameterReference}, {optionParam}, {dataMember})";
211211

212-
if (options.IsConvertable(typeIdentifier.TypeSymbol))
213-
return invocation;
214-
215-
return typeIdentifier is UnknownType
216-
? $"{AttributeValueUtilityFactory.ToAttributeValue}({invocation})"
217-
: invocation;
212+
return options.IsUnknown(typeIdentifier) is false
213+
? invocation
214+
: $"{AttributeValueUtilityFactory.ToAttributeValue}({invocation})";
218215
}
219216

220217
internal static IEnumerable<string> RootSignature(TypeIdentifier typeIdentifier)

src/DynamoDBGenerator.SourceGenerator/Generations/UnMarshaller.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,11 @@ private static IEnumerable<string> CreateTypeContents(IEnumerable<DynamoDBMarsha
225225

226226
private static string InvokeUnmarshallMethod(TypeIdentifier typeIdentifier, string paramReference, string dataMember, MarshallerOptions options, string marshallerOptionsReference = MarshallerOptions.ParamReference)
227227
{
228-
if (options.IsConvertable(typeIdentifier.TypeSymbol))
228+
if (options.IsUnknown(typeIdentifier) is false)
229229
return $"{GetDeserializationMethodName(typeIdentifier.TypeSymbol)}({paramReference}, {marshallerOptionsReference}, {dataMember})";
230-
231-
return typeIdentifier is UnknownType
232-
? $"{GetDeserializationMethodName(typeIdentifier.TypeSymbol)}({paramReference}?.M, {marshallerOptionsReference}, {dataMember})"
233-
: $"{GetDeserializationMethodName(typeIdentifier.TypeSymbol)}({paramReference}, {marshallerOptionsReference}, {dataMember})";
230+
231+
return
232+
$"{GetDeserializationMethodName(typeIdentifier.TypeSymbol)}({paramReference}?.M, {marshallerOptionsReference}, {dataMember})";
234233

235234
}
236235
private static IEnumerable<string> ObjectAssignmentBlock(bool useParentheses, IEnumerable<string> assignments, bool applySemiColon)

src/DynamoDBGenerator.SourceGenerator/Types/MarshallerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public readonly struct MarshallerOptions
1818
public string FieldDeclaration { get; }
1919

2020
public bool IsUnknown(TypeIdentifier typeSymbol) =>
21-
typeSymbol is UnknownType && !IsConvertable(typeSymbol.TypeSymbol);
21+
typeSymbol is UnknownType && IsConvertable(typeSymbol.TypeSymbol) is false;
2222

2323

2424
private MarshallerOptions(

0 commit comments

Comments
 (0)