Skip to content

Commit

Permalink
Check if convertable as well
Browse files Browse the repository at this point in the history
  • Loading branch information
inputfalken committed Jun 14, 2024
1 parent 533c66a commit 19ada16
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,11 @@ private static IEnumerable<string> ObjectAssignmentBlock(bool useParentheses, IE

}

internal static IEnumerable<string> RootSignature(ITypeSymbol typeSymbol, string typeName, string methodName)
internal static IEnumerable<string> RootSignature(MarshallerOptions options, ITypeSymbol typeSymbol, string typeName, string methodName)
{
return $"public {typeName} {methodName}(Dictionary<{nameof(String)}, {Constants.AWSSDK_DynamoDBv2.AttributeValue}> entity)".CreateScope(
"ArgumentNullException.ThrowIfNull(entity);",
typeSymbol.TypeIdentifier() is UnknownType
options.IsConvertable(typeSymbol) is false || typeSymbol.TypeIdentifier() is UnknownType
? $"return {UnMarshallerClass}.{GetDeserializationMethodName(typeSymbol)}(entity, {MarshallerOptions.FieldReference});"
: "throw new Exception();");
}
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoDBGenerator.SourceGenerator/MarshallerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ private static IEnumerable<string> CreateImplementations(IEnumerable<DynamoDBMar
.CreateScope($"{MarshallerOptions.FieldReference} = {MarshallerOptions.ParamReference};", $"{KeyMarshaller.PrimaryKeyMarshallerReference} = {KeyMarshaller.AssignmentRoot(argument.EntityTypeSymbol)};");
var interfaceImplementation = constructor
.Concat(Marshaller.RootSignature(argument.EntityTypeSymbol, argument.AnnotatedEntityType))
.Concat(UnMarshaller.RootSignature(argument.EntityTypeSymbol, argument.AnnotatedEntityType, Constants.DynamoDBGenerator.Marshaller.UnmarshalMethodName))
.Concat(UnMarshaller.RootSignature(argument.ArgumentType, argument.AnnotatedArgumentType, Constants.DynamoDBGenerator.Marshaller.UnmarshalArgumentMethodName))
.Concat(UnMarshaller.RootSignature(options, argument.EntityTypeSymbol, argument.AnnotatedEntityType, Constants.DynamoDBGenerator.Marshaller.UnmarshalMethodName))
.Concat(UnMarshaller.RootSignature(options, argument.ArgumentType, argument.AnnotatedArgumentType, Constants.DynamoDBGenerator.Marshaller.UnmarshalArgumentMethodName))
.Concat(KeyMarshaller.IndexKeyMarshallerRootSignature(argument.EntityTypeSymbol))
.Concat(expressionValueMethod)
.Append(expressionMethodName)
Expand Down

0 comments on commit 19ada16

Please sign in to comment.