Skip to content

Commit b7e0b00

Browse files
committed
Minor fixes
1 parent 2cb89fb commit b7e0b00

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/DynamoDBGenerator.SourceGenerator/Generations/AttributeExpressionName.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
using System.Collections.Immutable;
21
using System.Runtime.CompilerServices;
32
using DynamoDBGenerator.SourceGenerator.Extensions;
43
using DynamoDBGenerator.SourceGenerator.Types;
@@ -81,10 +80,8 @@ private static IEnumerable<string> YieldSelector((bool IsUnknown, DynamoDbDataMe
8180
.Concat($"foreach (var x in ({x.DDB.DataMember.Name} as {x.AttributeInterfaceName}).{AttributeExpressionNameTrackerInterfaceAccessedNames}())".CreateScope("yield return x;"));
8281
return $"if ({x.DDB.DataMember.NameAsPrivateField}.IsValueCreated)".CreateScope(scope);
8382
}
84-
else
85-
{
86-
return $@"if ({x.DDB.DataMember.NameAsPrivateField}.IsValueCreated && new KeyValuePair<string, string>(""{x.DbRef}"", ""{x.DDB.AttributeName}"") is var {camelCase} && {SetFieldName}.Add({camelCase}))".CreateScope($"yield return {camelCase};");
87-
}
83+
84+
return $@"if ({x.DDB.DataMember.NameAsPrivateField}.IsValueCreated && new KeyValuePair<string, string>(""{x.DbRef}"", ""{x.DDB.AttributeName}"") is var {camelCase} && {SetFieldName}.Add({camelCase}))".CreateScope($"yield return {camelCase};");
8885
}
8986

9087
private static CodeFactory CreateStruct(ITypeSymbol typeSymbol, Func<ITypeSymbol, DynamoDbDataMember[]> fn, MarshallerOptions options)

src/DynamoDBGenerator.SourceGenerator/Generations/AttributeExpressionValue.cs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
using System.Collections.Immutable;
2-
using System.Reflection;
31
using System.Runtime.CompilerServices;
42
using DynamoDBGenerator.SourceGenerator.Extensions;
53
using DynamoDBGenerator.SourceGenerator.Types;
@@ -49,11 +47,10 @@ MarshallerOptions options
4947

5048
const string param = "entity";
5149

52-
5350
var yields = (typeSymbol switch
5451
{
55-
var x when x.IsNullable() => $"if ({param} is null)".CreateScope($"yield return new ({self}.Value, {AttributeValueUtilityFactory.Null});", "yield break;"),
56-
var x when x.IsReferenceType => $"if ({param} is null)".CreateScope($"throw {ExceptionHelper.NullExceptionMethod}(\"{structName}\");"),
52+
_ when typeSymbol.IsNullable() => $"if ({param} is null)".CreateScope($"yield return new ({self}.Value, {AttributeValueUtilityFactory.Null});", "yield break;"),
53+
{ IsReferenceType: true } => $"if ({param} is null)".CreateScope($"throw {ExceptionHelper.NullExceptionMethod}(\"{structName}\");"),
5754
_ => Enumerable.Empty<string>()
5855
})
5956
.Concat(dataMembers

0 commit comments

Comments
 (0)