Skip to content

Commit

Permalink
fix: run csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Apr 19, 2023
1 parent d000c14 commit c204c44
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public static class DictionaryMappingBuilder
false,
objectFactory: objectFactory,
explicitCast: GetExplicitIndexer(ctx),
ensureCapacity: ensureCapacityStatement);
ensureCapacity: ensureCapacityStatement
);
}

public static IExistingTargetMapping? TryBuildExistingTargetMapping(MappingBuilderContext ctx)
Expand All @@ -102,7 +103,8 @@ public static class DictionaryMappingBuilder
keyMapping,
valueMapping,
explicitCast: GetExplicitIndexer(ctx),
ensureCapacity: ensureCapacityStatement);
ensureCapacity: ensureCapacityStatement
);
}

private static (ITypeMapping, ITypeMapping)? BuildKeyValueMapping(MappingBuilderContext ctx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public ForEachSetDictionaryExistingTargetMapping(
ITypeMapping keyMapping,
ITypeMapping valueMapping,
INamedTypeSymbol? explicitCast,
EnsureCapacity? ensureCapacity)
EnsureCapacity? ensureCapacity
)
: base(sourceType, targetType)
{
_keyMapping = keyMapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ public ForEachSetDictionaryMapping(
ITypeSymbol? typeToInstantiate = null,
ObjectFactory? objectFactory = null,
INamedTypeSymbol? explicitCast = null,
EnsureCapacity? ensureCapacity = null)
: base(new ForEachSetDictionaryExistingTargetMapping(sourceType, targetType, keyMapping, valueMapping, explicitCast, ensureCapacity))
EnsureCapacity? ensureCapacity = null
)
: base(
new ForEachSetDictionaryExistingTargetMapping(sourceType, targetType, keyMapping, valueMapping, explicitCast, ensureCapacity)
)
{
_sourceHasCount = sourceHasCount;
_objectFactory = objectFactory;
Expand Down
27 changes: 18 additions & 9 deletions test/Riok.Mapperly.Tests/Mapping/DictionaryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ public void DictionaryToCustomDictionaryWithObjectFactory()
public void MapToExistingDictionary()
{
var source = TestSourceBuilder.MapperWithBodyAndTypes(
"partial void Map(IDictionary<string, int> source, Dictionary<string, int> target);");
TestHelper.GenerateMapper(source)
"partial void Map(IDictionary<string, int> source, Dictionary<string, int> target);"
);
TestHelper
.GenerateMapper(source)
.Should()
.HaveSingleMethodBody(
"""
Expand All @@ -243,16 +245,19 @@ public void MapToExistingDictionary()
{
target[item.Key] = item.Value;
}
""");
"""
);
}

[Fact]
public void MapToExistingCustomDictionary()
{
var source = TestSourceBuilder.MapperWithBodyAndTypes(
"partial void Map(IDictionary<string, int> source, A target);",
"class A : Dictionary<string, int> {}");
TestHelper.GenerateMapper(source)
"class A : Dictionary<string, int> {}"
);
TestHelper
.GenerateMapper(source)
.Should()
.HaveSingleMethodBody(
"""
Expand All @@ -261,15 +266,18 @@ public void MapToExistingCustomDictionary()
{
target[item.Key] = item.Value;
}
""");
"""
);
}

[Fact]
public void KeyValueEnumerableToExistingDictionary()
{
var source = TestSourceBuilder.MapperWithBodyAndTypes(
"partial void Map(IEnumerable<KeyValuePair<string, int>> source, Dictionary<string, int> target);");
TestHelper.GenerateMapper(source)
"partial void Map(IEnumerable<KeyValuePair<string, int>> source, Dictionary<string, int> target);"
);
TestHelper
.GenerateMapper(source)
.Should()
.HaveSingleMethodBody(
"""
Expand All @@ -282,7 +290,8 @@ public void KeyValueEnumerableToExistingDictionary()
{
target[item.Key] = item.Value;
}
""");
"""
);
}

[Fact]
Expand Down

0 comments on commit c204c44

Please # to comment.