Skip to content

Commit 96b619d

Browse files
committed
Make properties static
1 parent 7b0ed7e commit 96b619d

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/DynamoDBGenerator.SourceGenerator/DynamoDbMarshaller.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ private static IEnumerable<string> CreateImplementations(IEnumerable<DynamoDBMar
3838
yield return options.TryInstantiate() switch
3939
{
4040
{} arg =>
41-
$"public {Interface}<{entityTypeName}, {argumentTypeName}, {nameTrackerTypeName}, {valueTrackerTypeName}> {argument.PropertyName} {{ get; }} = new {argument.ImplementationName}({arg});",
42-
null => $"public {Interface}<{entityTypeName}, {argumentTypeName}, {nameTrackerTypeName}, {valueTrackerTypeName}> {argument.PropertyName}({MarshallerOptions.Name} options) => new {argument.ImplementationName}(options);"
41+
$"public static {Interface}<{entityTypeName}, {argumentTypeName}, {nameTrackerTypeName}, {valueTrackerTypeName}> {argument.PropertyName} {{ get; }} = new {argument.ImplementationName}({arg});",
42+
null => $"public static {Interface}<{entityTypeName}, {argumentTypeName}, {nameTrackerTypeName}, {valueTrackerTypeName}> {argument.PropertyName}({MarshallerOptions.Name} options) => new {argument.ImplementationName}(options);"
4343
};
4444

4545
foreach (var s in classImplementation)

tests/DynamoDB.SourceGenerator.Benchmarks/Program.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
[MemoryDiagnoser]
2222
public class Marshalling
2323
{
24-
private readonly Repository _repository;
2524
private readonly DynamoDBContext _context;
2625
private readonly DynamoDBOperationConfig _dynamoDbOperationConfig;
2726
private readonly PersonEntity _singleElement;
@@ -33,7 +32,6 @@ public Marshalling()
3332
fixture.Behaviors.OfType<ThrowingRecursionBehavior>().ToList().ForEach(b => fixture.Behaviors.Remove(b));
3433
fixture.Behaviors.Add(new OmitOnRecursionBehavior());
3534

36-
_repository = new();
3735
_context = new(new AmazonDynamoDBClient(RegionEndpoint.EUWest1));
3836
_dynamoDbOperationConfig = new()
3937
{
@@ -54,7 +52,7 @@ public Dictionary<string, AttributeValue> Marshall_AWS()
5452
[Benchmark]
5553
public Dictionary<string, AttributeValue> Marshall_SG()
5654
{
57-
return _repository.PersonEntityMarshaller.Marshall(_singleElement);
55+
return Repository.PersonEntityMarshaller.Marshall(_singleElement);
5856
}
5957

6058
[Benchmark]
@@ -66,7 +64,7 @@ public PersonEntity Unmarshall_AWS()
6664
[Benchmark]
6765
public PersonEntity Unmarshall_SG()
6866
{
69-
return _repository.PersonEntityMarshaller.Unmarshall(_attributeValues);
67+
return Repository.PersonEntityMarshaller.Unmarshall(_attributeValues);
7068
}
7169

7270
}

0 commit comments

Comments
 (0)