Skip to content

Commit b852b4f

Browse files
committed
Isolate creation of TypeIdentifier
1 parent 0c1d9d1 commit b852b4f

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

src/DynamoDBGenerator.SourceGenerator/Generations/AttributeExpressionName.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal static IEnumerable<string> CreateClasses(DynamoDBMarshallerArguments[]
2525

2626
return arguments
2727
.SelectMany(x =>
28-
CodeFactory.Create(x.EntityTypeSymbol.TypeIdentifier(), y => CreateStruct(y, getDynamoDbProperties, options), hashSet));
28+
CodeFactory.Create(x.EntityTypeSymbol, y => CreateStruct(y, getDynamoDbProperties, options), hashSet));
2929
}
3030

3131
private static IEnumerable<string> TypeContent(

src/DynamoDBGenerator.SourceGenerator/Generations/AttributeExpressionValue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ internal static IEnumerable<string> CreateClasses(DynamoDBMarshallerArguments[]
123123

124124
return arguments
125125
.SelectMany(x =>
126-
CodeFactory.Create(x.ArgumentType.TypeIdentifier(), y => CreateStruct(y, getDynamoDbProperties, options), hashSet));
126+
CodeFactory.Create(x.ArgumentType, y => CreateStruct(y, getDynamoDbProperties, options), hashSet));
127127
}
128128

129129
private static CodeFactory CreateStruct(TypeIdentifier typeIdentifier, Func<ITypeSymbol, DynamoDbDataMember[]> fn,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ internal static IEnumerable<string> CreateKeys(IEnumerable<DynamoDBMarshallerArg
7878
var hashSet = new HashSet<TypeIdentifier>(TypeIdentifier.Nullable);
7979

8080
return arguments
81-
.SelectMany(x => CodeFactory.Create(x.EntityTypeSymbol.TypeIdentifier(),
81+
.SelectMany(x => CodeFactory.Create(x.EntityTypeSymbol,
8282
y => StaticAttributeValueDictionaryKeys(y, getDynamoDbProperties, options), hashSet));
8383
}
8484

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ private static IEnumerable<string> TypeContent(DynamoDBMarshallerArguments[] arg
6464

6565
return arguments.SelectMany(x => CodeFactory
6666
.Create(
67-
x.EntityTypeSymbol.TypeIdentifier(),
67+
x.EntityTypeSymbol,
6868
y => CreateMethod(y, getDynamoDbProperties, options),
6969
hashset
7070
)
71-
.Concat(CodeFactory.Create(x.ArgumentType.TypeIdentifier(), y => CreateMethod(y, getDynamoDbProperties, options),
71+
.Concat(CodeFactory.Create(x.ArgumentType, y => CreateMethod(y, getDynamoDbProperties, options),
7272
hashset))
7373
)
7474
.Concat(KeyMarshaller.CreateKeys(arguments, getDynamoDbProperties, options));

src/DynamoDBGenerator.SourceGenerator/Generations/UnMarshaller.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private static IEnumerable<string> CreateTypeContents(IEnumerable<DynamoDBMarsha
216216
var hashSet = new HashSet<TypeIdentifier>(TypeIdentifier.Nullable);
217217
return arguments.SelectMany(x =>
218218
CodeFactory.Create(
219-
x.EntityTypeSymbol.TypeIdentifier(),
219+
x.EntityTypeSymbol,
220220
y => CreateMethod(y, getDynamoDbProperties, options),
221221
hashSet
222222
)

src/DynamoDBGenerator.SourceGenerator/Types/CodeFactory.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using DynamoDBGenerator.SourceGenerator.Extensions;
12
using Microsoft.CodeAnalysis;
23

34
namespace DynamoDBGenerator.SourceGenerator.Types;
@@ -27,6 +28,12 @@ public CodeFactory(IEnumerable<string> lines)
2728
private readonly IEnumerable<TypeIdentifier> _dependantTypes;
2829

2930
public static IEnumerable<string> Create(
31+
ITypeSymbol typeSymbol,
32+
Func<TypeIdentifier, CodeFactory> codeSelector,
33+
ISet<TypeIdentifier> handledTypes
34+
) => Execute(typeSymbol.TypeIdentifier(), codeSelector, handledTypes);
35+
36+
private static IEnumerable<string> Execute(
3037
TypeIdentifier typeSymbol,
3138
Func<TypeIdentifier, CodeFactory> codeSelector,
3239
ISet<TypeIdentifier> handledTypes
@@ -42,7 +49,7 @@ ISet<TypeIdentifier> handledTypes
4249
yield return s;
4350

4451
foreach (var nestedTypeSymbol in code._dependantTypes)
45-
foreach (var nestedCode in Create(nestedTypeSymbol, codeSelector, handledTypes))
52+
foreach (var nestedCode in Execute(nestedTypeSymbol, codeSelector, handledTypes))
4653
yield return nestedCode;
4754
}
4855
}

0 commit comments

Comments
 (0)