Skip to content

Commit b45b268

Browse files
committed
Use full path
1 parent eee92f6 commit b45b268

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

src/DynamoDBGenerator.SourceGenerator/DynamoDBDMarshaller.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private static IEnumerable<string> CreateFileContent(INamedTypeSymbol type, Comp
7373
}
7474

7575

76-
private static (MarshallerOptions, IEnumerable<DynamoDBMarshallerArguments>) CreateArguments(ISymbol type,
76+
private static (MarshallerOptions, IEnumerable<DynamoDBMarshallerArguments>) CreateArguments(INamedTypeSymbol type,
7777
Compilation compilation)
7878
{
7979
var attributes = type.GetAttributes();
@@ -103,7 +103,7 @@ private static (MarshallerOptions, IEnumerable<DynamoDBMarshallerArguments>) Cre
103103
if (converter is null)
104104
throw new ArgumentException("Could not find converter implementation");
105105

106-
return (MarshallerOptions.Create(converter, enumStrategy), Arguments(attributes, type));
106+
return (MarshallerOptions.Create(type ,converter, enumStrategy), Arguments(attributes, type));
107107

108108
static IEnumerable<DynamoDBMarshallerArguments> Arguments(ImmutableArray<AttributeData> attributes,
109109
ISymbol type)

src/DynamoDBGenerator.SourceGenerator/Types/MarshallerOptions.cs

+15-6
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,37 @@ public readonly struct MarshallerOptions
88
{
99
private readonly INamedTypeSymbol _convertersType;
1010
private readonly int _enumStrategy;
11+
// TODO name needs to take namespace etc into account in order to make it accessible from the outside.
1112
public const string Name = "MarshallerOptions";
1213
public const string FieldReference = "_options";
1314
public const string ParamReference = "options";
1415
private const string ConvertersProperty = "Converters";
1516
public const string FieldDeclaration = $"private readonly {Name} {FieldReference};";
1617
private readonly string _converterFullPath;
18+
private readonly string _optionsFullPath;
1719

18-
private MarshallerOptions(INamedTypeSymbol convertersType,
19-
IEnumerable<KeyValuePair<string, ITypeSymbol>> converters, int enumStrategy)
20+
21+
private MarshallerOptions(
22+
INamedTypeSymbol orignalType,
23+
INamedTypeSymbol convertersType,
24+
IEnumerable<KeyValuePair<string, ITypeSymbol>> converters,
25+
int enumStrategy
26+
)
2027
{
2128
Converters = converters.ToDictionary(x => x.Value, x => x, SymbolEqualityComparer.Default);
2229
_convertersType = convertersType;
2330
_enumStrategy = enumStrategy;
2431
_converterFullPath = _convertersType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
32+
_optionsFullPath =
33+
$"{orignalType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat)}.{Name}";
2534
}
2635

2736
public string? TryInstantiate()
2837
{
2938
if (_convertersType.InstanceConstructors.Length is 0 ||
3039
_convertersType.InstanceConstructors.All(x => x.Parameters.Length is 0))
3140
{
32-
return $"new {Name}(new {_converterFullPath}())";
41+
return $"new {_optionsFullPath}(new {_converterFullPath}())";
3342
}
3443

3544
return null;
@@ -100,15 +109,15 @@ public IEnumerable<string> ClassDeclaration
100109
}
101110
}
102111

103-
public static MarshallerOptions Create(INamedTypeSymbol typeSymbol, int enumStrategy)
112+
public static MarshallerOptions Create(INamedTypeSymbol orignalType,INamedTypeSymbol converterTypeSymbol, int enumStrategy)
104113
{
105-
var keyValuePairs = typeSymbol
114+
var keyValuePairs = converterTypeSymbol
106115
.GetMembersToObject()
107116
.Select(ConverterDataMemberOrNull)
108117
.Where(x => x.HasValue)
109118
.Select(x => x!.Value);
110119

111-
return new MarshallerOptions(typeSymbol, keyValuePairs, enumStrategy);
120+
return new MarshallerOptions(orignalType, converterTypeSymbol, keyValuePairs, enumStrategy);
112121
}
113122

114123
private static KeyValuePair<string, ITypeSymbol>? ConverterDataMemberOrNull(ISymbol symbol)

0 commit comments

Comments
 (0)